QIdentityProxyModel Class
QIdentityProxyModel 클래스는 소스 모델을 수정하지 않고 프록시합니다. 더 보기...
Header: | #include <QIdentityProxyModel> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
상속합니다: | QAbstractProxyModel |
공용 함수
QIdentityProxyModel(QObject *parent = nullptr) | |
virtual | ~QIdentityProxyModel() |
(since 6.8) bool | handleSourceDataChanges() const |
(since 6.8) bool | handleSourceLayoutChanges() const |
재구현된 공용 함수
virtual int | columnCount(const QModelIndex &parent = QModelIndex()) const override |
virtual bool | dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override |
virtual QVariant | headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override |
virtual QModelIndex | index(int row, int column, const QModelIndex &parent = QModelIndex()) const override |
virtual bool | insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override |
virtual bool | insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override |
virtual QModelIndex | mapFromSource(const QModelIndex &sourceIndex) const override |
virtual QItemSelection | mapSelectionFromSource(const QItemSelection &selection) const override |
virtual QItemSelection | mapSelectionToSource(const QItemSelection &selection) const override |
virtual QModelIndex | mapToSource(const QModelIndex &proxyIndex) const override |
virtual QModelIndexList | match(const QModelIndex &start, int role, const QVariant &value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const override |
virtual bool | moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild) override |
virtual bool | moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override |
virtual QModelIndex | parent(const QModelIndex &child) const override |
virtual bool | removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override |
virtual bool | removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override |
virtual int | rowCount(const QModelIndex &parent = QModelIndex()) const override |
virtual void | setSourceModel(QAbstractItemModel *newSourceModel) override |
virtual QModelIndex | sibling(int row, int column, const QModelIndex &idx) const override |
보호된 함수
(since 6.8) void | setHandleSourceDataChanges(bool b) |
(since 6.8) void | setHandleSourceLayoutChanges(bool b) |
상세 설명
QIdentityProxyModel은 소스 모델의 구조를 정렬, 필터링 또는 기타 변환 없이 정확하게 전달하는 데 사용할 수 있습니다. 이는 인공지능 = A인 아이덴티티 매트릭스와 개념이 유사합니다.
이 클래스는 정렬이나 필터링을 수행하지 않으므로 소스 모델의 data()를 변환하는 프록시 모델에 가장 적합합니다. 예를 들어 프록시 모델을 생성하여 사용되는 글꼴, 배경색, 툴팁 등을 정의할 수 있습니다. 이렇게 하면 모델의 구조를 만드는 동일한 클래스에서 모든 데이터 처리를 구현할 필요가 없으며 재사용 가능한 컴포넌트를 만드는 데에도 사용할 수 있습니다.
또한 타사에서 제공한 소스 모델을 수정할 수 없는 경우 데이터를 변경할 수 있는 방법도 제공합니다.
class DateFormatProxyModel : public QIdentityProxyModel { // ... void setDateFormatString(const QString &formatString) { m_formatString = formatString; } QVariant data(const QModelIndex &index, int role) const override { if (role != Qt::DisplayRole) return QIdentityProxyModel::data(index, role); const QModelIndex sourceIndex = mapToSource(index); const QDateTime dateTime = sourceModel()->data(sourceIndex, SourceClass::DateRole).toDateTime(); return dateTime.toString(m_formatString); } QMap<int, QVariant> itemData(const QModelIndex &proxyIndex) const override { QMap<int, QVariant> map = QIdentityProxyModel::itemData(proxyIndex); map[Qt::DisplayRole] = data(proxyIndex); return map; } private: QString m_formatString; };
QAbstractProxyModel, 모델/보기 프로그래밍 및 QAbstractItemModel 을참조하세요 .
멤버 함수 문서
[explicit]
QIdentityProxyModel::QIdentityProxyModel(QObject *parent = nullptr)
주어진 parent 으로 ID 모델을 구축합니다.
[virtual noexcept]
QIdentityProxyModel::~QIdentityProxyModel()
이 ID 모델을 파괴합니다.
[override virtual]
int QIdentityProxyModel::columnCount(const QModelIndex &parent = QModelIndex()) const
재구현합니다: QAbstractItemModel::columnCount(const QModelIndex &parent) const.
[override virtual]
bool QIdentityProxyModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
재구현합니다: QAbstractProxyModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent).
[since 6.8]
bool QIdentityProxyModel::handleSourceDataChanges() const
이 프록시 모델이 소스 모델 데이터 변경을 처리하면 true
을 반환하고, 그렇지 않으면 false
을 반환합니다.
이 함수는 Qt 6.8에 도입되었습니다.
setHandleSourceDataChanges()도 참조하십시오 .
[since 6.8]
bool QIdentityProxyModel::handleSourceLayoutChanges() const
이 프록시 모델이 소스 모델 레이아웃 변경을 처리하면 true
을 반환하고, 그렇지 않으면 false
을 반환합니다.
이 함수는 Qt 6.8에 도입되었습니다.
setHandleSourceLayoutChanges()도 참조하십시오 .
[override virtual]
QVariant QIdentityProxyModel::headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const
재구현합니다: QAbstractProxyModel::headerData(int section, Qt::오리엔테이션 방향, int 역할) const.
[override virtual]
QModelIndex QIdentityProxyModel::index(int row, int column, const QModelIndex &parent = QModelIndex()) const
재구현합니다: QAbstractItemModel::index(int row, int column, const QModelIndex &parent) const.
[override virtual]
bool QIdentityProxyModel::insertColumns(int column, int count, const QModelIndex &parent = QModelIndex())
재구현합니다: QAbstractItemModel::insertColumns(int column, int count, const QModelIndex &parent).
[override virtual]
bool QIdentityProxyModel::insertRows(int row, int count, const QModelIndex &parent = QModelIndex())
재구현합니다: QAbstractItemModel::insertRows(int row, int count, const QModelIndex &parent).
[override virtual]
QModelIndex QIdentityProxyModel::mapFromSource(const QModelIndex &sourceIndex) const
재구현합니다: QAbstractProxyModel::mapFromSource(const QModelIndex &sourceIndex) const.
[override virtual]
QItemSelection QIdentityProxyModel::mapSelectionFromSource(const QItemSelection &selection) const
재구현합니다: QAbstractProxyModel::mapSelectionFromSource(const QItemSelection &sourceSelection) const.
[override virtual]
QItemSelection QIdentityProxyModel::mapSelectionToSource(const QItemSelection &selection) const
재구현합니다: QAbstractProxyModel::mapSelectionToSource(const QItemSelection &proxySelection) const.
[override virtual]
QModelIndex QIdentityProxyModel::mapToSource(const QModelIndex &proxyIndex) const
재구현합니다: QAbstractProxyModel::mapToSource(const QModelIndex &proxyIndex) const.
[override virtual]
QModelIndexList QIdentityProxyModel::match(const QModelIndex &start, int role, const QVariant &value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const
재 구현합니다: QAbstractItemModel::match(const QModelIndex &start, int role, const QVariant &value, int hits, Qt::MatchFlags flags) const.
[override virtual]
bool QIdentityProxyModel::moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild)
재구현합니다: QAbstractItemModel::moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild).
[override virtual]
bool QIdentityProxyModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild)
재구현합니다: QAbstractItemModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild).
[override virtual]
QModelIndex QIdentityProxyModel::parent(const QModelIndex &child) const
재구현합니다: QAbstractItemModel::parent(const QModelIndex &index) const.
[override virtual]
bool QIdentityProxyModel::removeColumns(int column, int count, const QModelIndex &parent = QModelIndex())
재구현합니다: QAbstractItemModel::removeColumns(int column, int count, const QModelIndex &parent).
[override virtual]
bool QIdentityProxyModel::removeRows(int row, int count, const QModelIndex &parent = QModelIndex())
재구현합니다: QAbstractItemModel::removeRows(int row, int count, const QModelIndex &parent).
[override virtual]
int QIdentityProxyModel::rowCount(const QModelIndex &parent = QModelIndex()) const
재구현합니다: QAbstractItemModel::rowCount(const QModelIndex &parent) const.
[protected, since 6.8]
void QIdentityProxyModel::setHandleSourceDataChanges(bool b)
b 이 true
인 경우 이 프록시 모델은 소스 모델 데이터 변경을 처리합니다( QAbstractItemModel::dataChanged
신호에 연결하여).
기본값은 이 프록시 모델이 소스 모델 데이터 변경을 처리하는 것입니다.
QIdentityProxyModel 의 하위 클래스에서 소스 모델 데이터 변경을 특별히 처리해야 하는 경우 false
으로 설정하는 것이 유용할 수 있습니다.
참고: 이 메서드를 호출하면 setSourceModel()를 호출한 후에만 효과가 있습니다.
이 함수는 Qt 6.8에 도입되었습니다.
handleSourceDataChanges()도 참조하세요 .
[protected, since 6.8]
void QIdentityProxyModel::setHandleSourceLayoutChanges(bool b)
b 가 true
인 경우 이 프록시 모델은 소스 모델 레이아웃 변경을 처리합니다( QAbstractItemModel::layoutAboutToBeChanged
및 QAbstractItemModel::layoutChanged
신호에 연결하여).
기본값은 이 프록시 모델이 소스 모델 레이아웃 변경을 처리하는 것입니다.
QIdentityProxyModel 의 하위 클래스에서 소스 모델 레이아웃 변경을 특별히 처리해야 하는 경우 false
으로 설정하는 것이 유용할 수 있습니다.
참고: 이 메서드를 호출하면 setSourceModel()를 호출한 후에만 효과가 있습니다.
이 함수는 Qt 6.8에 도입되었습니다.
handleSourceLayoutChanges()도 참조하세요 .
[override virtual]
void QIdentityProxyModel::setSourceModel(QAbstractItemModel *newSourceModel)
재구현합니다: QAbstractProxyModel::setSourceModel(QAbstractItemModel *sourceModel).
[override virtual]
QModelIndex QIdentityProxyModel::sibling(int row, int column, const QModelIndex &idx) const
재구현합니다: QAbstractProxyModel::sibling(int row, int column, const QModelIndex &idx) const.
© 2025 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.