QAbstractProxyModel 类为代理项模型提供可以履行排序、过滤或其它数据处理任务的基类。 更多...
头: | #include <QAbstractProxyModel> |
qmake: | QT += core |
Since: | Qt 4.1 |
继承: | QAbstractItemModel |
继承者: |
QIdentityProxyModel , QSortFilterProxyModel ,和 QTransposeProxyModel |
该类在 Qt 4.1 引入。
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 () |
void | resetInternalData () |
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 .
To subclass 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 ,和 模型/视图编程 .
此特性保持此代理模型的源模型。
访问函数:
QAbstractItemModel * | sourceModel () const |
virtual void | setSourceModel (QAbstractItemModel * sourceModel ) |
通知程序信号:
void | sourceModelChanged () | [见下文注意事项] |
注意: 这是私有信号。它可以用于信号连接,但不能由用户发射。
Constructs a proxy model with the given parent .
[protected slot]
void
QAbstractProxyModel::
resetInternalData
()
清零 roleNames of this proxy model.
[虚拟]
QAbstractProxyModel::
~QAbstractProxyModel
()
Destroys the proxy model.
[override virtual]
QModelIndex
QAbstractProxyModel::
buddy
(const
QModelIndex
&
index
) const
重实现: QAbstractItemModel::buddy (const QModelIndex &index) const.
[override virtual]
bool
QAbstractProxyModel::
canDropMimeData
(const
QMimeData
*
data
,
Qt::DropAction
action
,
int
row
,
int
column
, const
QModelIndex
&
parent
) const
重实现: QAbstractItemModel::canDropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const.
该函数在 Qt 5.4 引入。
[override virtual]
bool
QAbstractProxyModel::
canFetchMore
(const
QModelIndex
&
parent
) const
重实现: QAbstractItemModel::canFetchMore (const QModelIndex &parent) const.
[override virtual]
QVariant
QAbstractProxyModel::
data
(const
QModelIndex
&
proxyIndex
,
int
role
= Qt::DisplayRole) const
重实现: QAbstractItemModel::data (const QModelIndex &index, int role) const.
另请参阅 setData ().
[override virtual]
bool
QAbstractProxyModel::
dropMimeData
(const
QMimeData
*
data
,
Qt::DropAction
action
,
int
row
,
int
column
, const
QModelIndex
&
parent
)
重实现: QAbstractItemModel::dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent).
该函数在 Qt 5.4 引入。
[override virtual]
void
QAbstractProxyModel::
fetchMore
(const
QModelIndex
&
parent
)
重实现: QAbstractItemModel::fetchMore (const QModelIndex &parent).
[override virtual]
Qt::ItemFlags
QAbstractProxyModel::
flags
(const
QModelIndex
&
index
) const
重实现: QAbstractItemModel::flags (const QModelIndex &index) const.
[override virtual]
bool
QAbstractProxyModel::
hasChildren
(const
QModelIndex
&
parent
= QModelIndex()) const
重实现: QAbstractItemModel::hasChildren (const QModelIndex &parent) const.
[override virtual]
QVariant
QAbstractProxyModel::
headerData
(
int
section
,
Qt::Orientation
orientation
,
int
role
= Qt::DisplayRole) const
重实现: QAbstractItemModel::headerData (int section, Qt::Orientation orientation, int role) const.
另请参阅 setHeaderData ().
[override virtual]
QMap
<
int
,
QVariant
> QAbstractProxyModel::
itemData
(const
QModelIndex
&
proxyIndex
) const
重实现: QAbstractItemModel::itemData (const QModelIndex &index) const.
另请参阅 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 (const QModelIndexList &indexes) const.
[override virtual]
QStringList
QAbstractProxyModel::
mimeTypes
() const
重实现: QAbstractItemModel::mimeTypes () const.
[override virtual]
void
QAbstractProxyModel::
revert
()
重实现: QAbstractItemModel::revert ().
[override virtual]
bool
QAbstractProxyModel::
setData
(const
QModelIndex
&
index
, const
QVariant
&
value
,
int
role
= Qt::EditRole)
重实现: QAbstractItemModel::setData (const QModelIndex &index, const QVariant &value, int role).
另请参阅 data ().
[override virtual]
bool
QAbstractProxyModel::
setHeaderData
(
int
section
,
Qt::Orientation
orientation
, const
QVariant
&
value
,
int
role
= Qt::EditRole)
重实现: QAbstractItemModel::setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role).
另请参阅 headerData ().
[override virtual]
bool
QAbstractProxyModel::
setItemData
(const
QModelIndex
&
index
, const
QMap
<
int
,
QVariant
> &
roles
)
重实现: QAbstractItemModel::setItemData (const QModelIndex &index, const QMap<int, QVariant> &roles).
另请参阅 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 (int row, int column, const QModelIndex &index) const.
[override virtual]
void
QAbstractProxyModel::
sort
(
int
column
,
Qt::SortOrder
order
= Qt::AscendingOrder)
重实现: QAbstractItemModel::sort (int column, Qt::SortOrder order).
Returns the model that contains the data that is available through the proxy model.
注意: Getter function for property sourceModel.
另请参阅 setSourceModel ().
[override virtual]
QSize
QAbstractProxyModel::
span
(const
QModelIndex
&
index
) const
重实现: QAbstractItemModel::span (const QModelIndex &index) const.
[override virtual]
bool
QAbstractProxyModel::
submit
()
重实现: QAbstractItemModel::submit ().
[override virtual]
Qt::DropActions
QAbstractProxyModel::
supportedDragActions
() const
重实现: QAbstractItemModel::supportedDragActions () const.
[override virtual]
Qt::DropActions
QAbstractProxyModel::
supportedDropActions
() const
重实现: QAbstractItemModel::supportedDropActions () const.