QAbstractProxyModel 类

The QAbstractProxyModel class provides a base class for proxy item models that can do sorting, filtering or other data processing tasks. 更多...

头: #include <QAbstractProxyModel>
qmake: QT += core
Since: Qt 4.1
继承: QAbstractItemModel
继承者: QIdentityProxyModel and QSortFilterProxyModel

特性

公共函数

QAbstractProxyModel (QObject * parent = nullptr)
virtual ~QAbstractProxyModel ()
virtual QModelIndex mapFromSource (const QModelIndex & sourceIndex ) const = 0
virtual QItemSelection mapSelectionFromSource (const QItemSelection & sourceSelection ) const
virtual QItemSelection mapSelectionToSource (const QItemSelection & proxySelection ) const
virtual QModelIndex mapToSource (const QModelIndex & proxyIndex ) const = 0
virtual void setSourceModel (QAbstractItemModel * sourceModel )
QAbstractItemModel * sourceModel () const

重实现公共函数

virtual QModelIndex buddy (const QModelIndex & index ) const override
virtual bool canDropMimeData (const QMimeData * data , Qt::DropAction action , int row , int column , const QModelIndex & parent ) const override
virtual bool canFetchMore (const QModelIndex & parent ) const override
virtual QVariant data (const QModelIndex & proxyIndex , int role = Qt::DisplayRole) const override
virtual bool dropMimeData (const QMimeData * data , Qt::DropAction action , int row , int column , const QModelIndex & parent ) override
virtual void fetchMore (const QModelIndex & parent ) override
virtual Qt::ItemFlags flags (const QModelIndex & index ) const override
virtual bool hasChildren (const QModelIndex & parent = QModelIndex()) const override
virtual QVariant headerData (int section , Qt::Orientation orientation , int role = Qt::DisplayRole) const override
virtual QMap<int, QVariant> itemData (const QModelIndex & proxyIndex ) const override
virtual QMimeData * mimeData (const QModelIndexList & indexes ) const override
virtual QStringList mimeTypes () const override
virtual void revert () override
virtual bool setData (const QModelIndex & index , const QVariant & value , int role = Qt::EditRole) override
virtual bool setHeaderData (int section , Qt::Orientation orientation , const QVariant & value , int role = Qt::EditRole) override
virtual bool setItemData (const QModelIndex & index , const QMap<int, QVariant> & roles ) override
virtual QModelIndex sibling (int row , int column , const QModelIndex & idx ) const override
virtual void sort (int column , Qt::SortOrder order = Qt::AscendingOrder) override
virtual QSize span (const QModelIndex & index ) const override
virtual bool submit () override
virtual Qt::DropActions supportedDragActions () const override
virtual Qt::DropActions supportedDropActions () const override

信号

void sourceModelChanged ()

静态公共成员

const QMetaObject staticMetaObject

保护槽

void resetInternalData ()

额外继承成员

详细描述

The QAbstractProxyModel class provides a base class for proxy item models that can do sorting, filtering or other data processing tasks.

This class defines the standard interface that proxy models must use to be able to interoperate correctly with other model/view components. It is not supposed to be instantiated directly.

All standard proxy models are derived from the QAbstractProxyModel class. If you need to create a new proxy model class, it is usually better to subclass an existing class that provides the closest behavior to the one you want to provide.

Proxy models that filter or sort items of data from a source model should be created by using or subclassing QSortFilterProxyModel .

要子类化 QAbstractProxyModel , you need to implement mapFromSource () 和 mapToSource ()。 mapSelectionFromSource () 和 mapSelectionToSource () functions only need to be reimplemented if you need a behavior different from the default behavior.

注意: If the source model is deleted or no source model is specified, the proxy model operates on a empty placeholder model.

另请参阅 QSortFilterProxyModel , QAbstractItemModel ,和 模型/视图编程 .

特性文档编制

sourceModel : QAbstractItemModel *

此特性保持此代理模型的源模型。

访问函数:

QAbstractItemModel * sourceModel () const
virtual void setSourceModel (QAbstractItemModel * sourceModel )

通知程序信号:

void sourceModelChanged () [见下文注意事项]

注意: 这是私有信号。它可以用于信号连接,但不能由用户发射。

成员函数文档编制

QAbstractProxyModel:: QAbstractProxyModel ( QObject * parent = nullptr)

Constructs a proxy model with the given parent .

[虚拟] QAbstractProxyModel:: ~QAbstractProxyModel ()

Destroys the proxy model.

[override virtual] QModelIndex QAbstractProxyModel:: buddy (const QModelIndex & index ) const

重实现自 QAbstractItemModel::buddy ().

[override virtual] bool QAbstractProxyModel:: canDropMimeData (const QMimeData * data , Qt::DropAction action , int row , int column , const QModelIndex & parent ) const

重实现自 QAbstractItemModel::canDropMimeData ().

该函数在 Qt 5.4 引入。

[override virtual] bool QAbstractProxyModel:: canFetchMore (const QModelIndex & parent ) const

重实现自 QAbstractItemModel::canFetchMore ().

[override virtual] QVariant QAbstractProxyModel:: data (const QModelIndex & proxyIndex , int role = Qt::DisplayRole) const

重实现自 QAbstractItemModel::data ().

另请参阅 setData ().

[override virtual] bool QAbstractProxyModel:: dropMimeData (const QMimeData * data , Qt::DropAction action , int row , int column , const QModelIndex & parent )

重实现自 QAbstractItemModel::dropMimeData ().

该函数在 Qt 5.4 引入。

[override virtual] void QAbstractProxyModel:: fetchMore (const QModelIndex & parent )

重实现自 QAbstractItemModel::fetchMore ().

[override virtual] Qt::ItemFlags QAbstractProxyModel:: flags (const QModelIndex & index ) const

重实现自 QAbstractItemModel::flags ().

[override virtual] bool QAbstractProxyModel:: hasChildren (const QModelIndex & parent = QModelIndex()) const

重实现自 QAbstractItemModel::hasChildren ().

[override virtual] QVariant QAbstractProxyModel:: headerData ( int section , Qt::Orientation orientation , int role = Qt::DisplayRole) const

重实现自 QAbstractItemModel::headerData ().

另请参阅 setHeaderData ().

[override virtual] QMap < int , QVariant > QAbstractProxyModel:: itemData (const QModelIndex & proxyIndex ) const

重实现自 QAbstractItemModel::itemData ().

另请参阅 setItemData ().

[pure virtual] QModelIndex QAbstractProxyModel:: mapFromSource (const QModelIndex & sourceIndex ) const

Reimplement this function to return the model index in the proxy model that corresponds to the sourceIndex from the source model.

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

另请参阅 mapToSource ().

[虚拟] QItemSelection QAbstractProxyModel:: mapSelectionFromSource (const QItemSelection & sourceSelection ) const

Returns a proxy selection mapped from the specified sourceSelection .

Reimplement this method to map source selections to proxy selections.

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

[虚拟] QItemSelection QAbstractProxyModel:: mapSelectionToSource (const QItemSelection & proxySelection ) const

Returns a source selection mapped from the specified proxySelection .

Reimplement this method to map proxy selections to source selections.

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

[pure virtual] QModelIndex QAbstractProxyModel:: mapToSource (const QModelIndex & proxyIndex ) const

Reimplement this function to return the model index in the source model that corresponds to the proxyIndex in the proxy model.

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

另请参阅 mapFromSource ().

[override virtual] QMimeData *QAbstractProxyModel:: mimeData (const QModelIndexList & indexes ) const

重实现自 QAbstractItemModel::mimeData ().

[override virtual] QStringList QAbstractProxyModel:: mimeTypes () const

重实现自 QAbstractItemModel::mimeTypes ().

[protected slot] void QAbstractProxyModel:: resetInternalData ()

清零 roleNames of this proxy model.

[override virtual] void QAbstractProxyModel:: revert ()

重实现自 QAbstractItemModel::revert ().

[override virtual] bool QAbstractProxyModel:: setData (const QModelIndex & index , const QVariant & value , int role = Qt::EditRole)

重实现自 QAbstractItemModel::setData ().

另请参阅 data ().

[override virtual] bool QAbstractProxyModel:: setHeaderData ( int section , Qt::Orientation orientation , const QVariant & value , int role = Qt::EditRole)

重实现自 QAbstractItemModel::setHeaderData ().

另请参阅 headerData ().

[override virtual] bool QAbstractProxyModel:: setItemData (const QModelIndex & index , const QMap < int , QVariant > & roles )

重实现自 QAbstractItemModel::setItemData ().

另请参阅 itemData ().

[虚拟] void QAbstractProxyModel:: setSourceModel ( QAbstractItemModel * sourceModel )

设置给定 sourceModel to be processed by the proxy model.

Subclasses should call beginResetModel () at the beginning of the method, disconnect from the old model, call this method, connect to the new model, and call endResetModel ().

注意: setter 函数对于特性 sourceModel .

另请参阅 sourceModel ().

[override virtual] QModelIndex QAbstractProxyModel:: sibling ( int row , int column , const QModelIndex & idx ) const

重实现自 QAbstractItemModel::sibling ().

[override virtual] void QAbstractProxyModel:: sort ( int column , Qt::SortOrder order = Qt::AscendingOrder)

重实现自 QAbstractItemModel::sort ().

QAbstractItemModel *QAbstractProxyModel:: sourceModel () const

Returns the model that contains the data that is available through the proxy model.

注意: getter 函数对于特性 sourceModel .

另请参阅 setSourceModel ().

[override virtual] QSize QAbstractProxyModel:: span (const QModelIndex & index ) const

重实现自 QAbstractItemModel::span ().

[override virtual] bool QAbstractProxyModel:: submit ()

重实现自 QAbstractItemModel::submit ().

[override virtual] Qt::DropActions QAbstractProxyModel:: supportedDragActions () const

重实现自 QAbstractItemModel::supportedDragActions ().

[override virtual] Qt::DropActions QAbstractProxyModel:: supportedDropActions () const

重实现自 QAbstractItemModel::supportedDropActions ().