QModelRoleData Class
QModelRoleData 클래스는 역할과 해당 역할에 연관된 데이터를 저장합니다. 더 보기...
| 헤더: | #include <QModelRoleData> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
| qmake: | QT += core |
| 다음부터: | Qt 6.0부터 |
공개 함수
| QModelRoleData(int role) | |
| void | clearData() |
| QVariant & | data() |
| const QVariant & | data() const |
| int | role() const |
| void | setData(T &&value) |
상세 설명
QModelRoleData 객체는 항목 역할( Qt::ItemDataRole 열거형의 값이거나 사용자 정의 역할의 경우 임의의 정수)과 해당 역할과 관련된 데이터를 저장합니다.
QModelRoleData 객체는 일반적으로 뷰나 델리게이트에 의해 생성되며, 이때 데이터를 가져올 역할을 설정합니다. 그런 다음 이 객체는 모델로 전달되어( QAbstractItemModel::multiData() 참조), 모델은 저장된 역할에 해당하는 데이터를 채웁니다. 마지막으로, 뷰는 모델에서 가져온 데이터를 시각화합니다.
‘모델/뷰 프로그래밍 ’ 및 ‘ QModelRoleDataSpan ’항목도 참조하십시오 .
멤버 함수 문서
[explicit noexcept] QModelRoleData::QModelRoleData(int role)
지정된 ` role`에 대한 `QModelRoleData` 객체를 생성합니다.
Qt::ItemDataRole도 참조하십시오 .
[noexcept] void QModelRoleData::clearData()
이 객체가 보유한 데이터를 지웁니다. 역할은 변경되지 않으며, 데이터만 지워진다는 점에 유의하십시오.
data()도 참조하십시오 .
[constexpr noexcept] QVariant &QModelRoleData::data()
이 객체가 보유한 데이터를 수정 가능한 참조로 반환합니다.
setData()도 참조하십시오 .
[constexpr noexcept] const QVariant &QModelRoleData::data() const
이 객체가 보유한 데이터를 반환합니다.
setData()도 참조하십시오 .
[constexpr noexcept] int QModelRoleData::role() const
이 객체가 가진 역할을 반환합니다.
Qt::ItemDataRole도 참조하십시오 .
[constexpr noexcept(...)] template <typename T> void QModelRoleData::setData(T &&value)
이 객체가 보유한 데이터를 ` value`로 설정합니다. ` value `는 ` QVariant`에 저장될 수 있는 데이터형이어야 합니다.
참고: noexcept(m_data.setValue(std::forward<T>(value))) 가 true 인 경우,이 함수는 noexcept를 따릅니다.
data(), clearData(), Q_DECLARE_METATYPE도 참조하십시오 .
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.