이 페이지에서

QIdentityProxyModel Class

QIdentityProxyModel 클래스는 소스 모델을 수정하지 않고 프록시합니다. 더 보기...

헤더: #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.I = A인 정체 행렬과 개념적으로 유사합니다.

정렬이나 필터링을 수행하지 않기 때문에, 이 클래스는 소스 모델의 ` data()`을 변환하는 프록시 모델에 가장 적합합니다. 예를 들어, 사용되는 글꼴, 배경색, 툴팁 등을 정의하기 위해 프록시 모델을 생성할 수 있습니다. 이를 통해 모델 구조를 생성하는 동일한 클래스에서 모든 데이터 처리를 구현할 필요가 없으며, 재사용 가능한 컴포넌트를 생성하는 데에도 사용할 수 있습니다.

또한, 수정할 수 없는 타사에서 제공한 소스 모델의 경우 데이터를 변경할 수 있는 방법도 제공합니다.

class DateFormatProxyModel : public QIdentityProxyModel
{
  // ...

  void setDateFormatString(const QString &formatString)
  {
    m_formatString = formatString;
  }

  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) 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, Model/View Programming 및 QAbstractItemModel도 참조하십시오 .

멤버 함수 문서

[explicit] QIdentityProxyModel::QIdentityProxyModel(QObject *parent = nullptr)

주어진 parent 를 사용하여 정체성 모델을 생성합니다.

[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::Orientation orientation, int role) 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를 재구현합니다.

© 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.