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 = Q_NULLPTR) | |
~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 |
virtual bool | canDropMimeData (const QMimeData * data , Qt::DropAction action , int row , int column , const QModelIndex & parent ) const |
virtual bool | canFetchMore (const QModelIndex & parent ) const |
virtual QVariant | data (const QModelIndex & proxyIndex , int role = Qt::DisplayRole) const |
virtual bool | dropMimeData (const QMimeData * data , Qt::DropAction action , int row , int column , const QModelIndex & parent ) |
virtual void | fetchMore (const QModelIndex & parent ) |
virtual Qt::ItemFlags | flags (const QModelIndex & index ) const |
virtual bool | hasChildren (const QModelIndex & parent = QModelIndex()) const |
virtual QVariant | headerData (int section , Qt::Orientation orientation , int role = Qt::DisplayRole) const |
virtual QMap<int, QVariant> | itemData (const QModelIndex & proxyIndex ) const |
virtual QMimeData * | mimeData (const QModelIndexList & indexes ) const |
virtual QStringList | mimeTypes () const |
virtual void | revert () |
virtual bool | setData (const QModelIndex & index , const QVariant & value , int role = Qt::EditRole) |
virtual bool | setHeaderData (int section , Qt::Orientation orientation , const QVariant & value , int role = Qt::EditRole) |
virtual bool | setItemData (const QModelIndex & index , const QMap<int, QVariant> & roles ) |
virtual QModelIndex | sibling (int row , int column , const QModelIndex & idx ) const |
virtual void | sort (int column , Qt::SortOrder order = Qt::AscendingOrder) |
virtual QSize | span (const QModelIndex & index ) const |
virtual bool | submit () |
virtual Qt::DropActions | supportedDragActions () const |
virtual Qt::DropActions | supportedDropActions () const |
void | sourceModelChanged () |
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 ,和 模型/视图编程 .
此特性保持此代理模型的源模型。
访问函数:
QAbstractItemModel * | sourceModel () const |
virtual void | setSourceModel (QAbstractItemModel * sourceModel ) |
通知程序信号:
void | sourceModelChanged () | [见下文注意事项] |
注意: 这是私有信号。它可以用于信号连接,但不能由用户发射。
Constructs a proxy model with the given parent .
Destroys the proxy model.
[虚拟]
QModelIndex
QAbstractProxyModel::
buddy
(const
QModelIndex
&
index
) const
重实现自 QAbstractItemModel::buddy ().
[虚拟]
bool
QAbstractProxyModel::
canDropMimeData
(const
QMimeData
*
data
,
Qt::DropAction
action
,
int
row
,
int
column
, const
QModelIndex
&
parent
) const
重实现自 QAbstractItemModel::canDropMimeData ().
该函数在 Qt 5.4 引入。
[虚拟]
bool
QAbstractProxyModel::
canFetchMore
(const
QModelIndex
&
parent
) const
重实现自 QAbstractItemModel::canFetchMore ().
[虚拟]
QVariant
QAbstractProxyModel::
data
(const
QModelIndex
&
proxyIndex
,
int
role
= Qt::DisplayRole) const
重实现自 QAbstractItemModel::data ().
另请参阅 setData ().
[虚拟]
bool
QAbstractProxyModel::
dropMimeData
(const
QMimeData
*
data
,
Qt::DropAction
action
,
int
row
,
int
column
, const
QModelIndex
&
parent
)
重实现自 QAbstractItemModel::dropMimeData ().
该函数在 Qt 5.4 引入。
[虚拟]
void
QAbstractProxyModel::
fetchMore
(const
QModelIndex
&
parent
)
重实现自 QAbstractItemModel::fetchMore ().
[虚拟]
Qt::ItemFlags
QAbstractProxyModel::
flags
(const
QModelIndex
&
index
) const
重实现自 QAbstractItemModel::flags ().
[虚拟]
bool
QAbstractProxyModel::
hasChildren
(const
QModelIndex
&
parent
= QModelIndex()) const
重实现自 QAbstractItemModel::hasChildren ().
[虚拟]
QVariant
QAbstractProxyModel::
headerData
(
int
section
,
Qt::Orientation
orientation
,
int
role
= Qt::DisplayRole) const
重实现自 QAbstractItemModel::headerData ().
另请参阅 setHeaderData ().
[虚拟]
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.
另请参阅 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.
[虚拟]
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.
[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.
另请参阅 mapFromSource ().
[虚拟]
QMimeData
*QAbstractProxyModel::
mimeData
(const
QModelIndexList
&
indexes
) const
重实现自 QAbstractItemModel::mimeData ().
[虚拟]
QStringList
QAbstractProxyModel::
mimeTypes
() const
重实现自 QAbstractItemModel::mimeTypes ().
[protected slot]
void
QAbstractProxyModel::
resetInternalData
()
清零 roleNames of this proxy model.
[虚拟]
void
QAbstractProxyModel::
revert
()
重实现自 QAbstractItemModel::revert ().
[虚拟]
bool
QAbstractProxyModel::
setData
(const
QModelIndex
&
index
, const
QVariant
&
value
,
int
role
= Qt::EditRole)
重实现自 QAbstractItemModel::setData ().
另请参阅 data ().
[虚拟]
bool
QAbstractProxyModel::
setHeaderData
(
int
section
,
Qt::Orientation
orientation
, const
QVariant
&
value
,
int
role
= Qt::EditRole)
重实现自 QAbstractItemModel::setHeaderData ().
另请参阅 headerData ().
[虚拟]
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 ().
[虚拟]
QModelIndex
QAbstractProxyModel::
sibling
(
int
row
,
int
column
, const
QModelIndex
&
idx
) const
重实现自 QAbstractItemModel::sibling ().
[虚拟]
void
QAbstractProxyModel::
sort
(
int
column
,
Qt::SortOrder
order
= Qt::AscendingOrder)
重实现自 QAbstractItemModel::sort ().
Returns the model that contains the data that is available through the proxy model.
注意: Getter 函数对于特性 sourceModel .
另请参阅 setSourceModel ().
[虚拟]
QSize
QAbstractProxyModel::
span
(const
QModelIndex
&
index
) const
重实现自 QAbstractItemModel::span ().
[虚拟]
bool
QAbstractProxyModel::
submit
()
重实现自 QAbstractItemModel::submit ().
[虚拟]
Qt::DropActions
QAbstractProxyModel::
supportedDragActions
() const
重实现自 QAbstractItemModel::supportedDragActions ().
[虚拟]
Qt::DropActions
QAbstractProxyModel::
supportedDropActions
() const