QAbstractProxyModel Class
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting, filtering or other data processing tasks. More…
| Header | #include <QAbstractProxyModel> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Core) |
| Module | Nt Core C++ Classes |
| Since | 4.1 |
| Inherits | QAbstractItemModel |
| Inherited by | QIdentityProxyModel, QSortFilterProxyModel, QTransposeProxyModel |
List of all members, including inherited members
Public Functions
| QAbstractProxyModel(QObject *parent = nullptr) | |
| ~QAbstractProxyModel() | |
| virtual void | setSourceModel(QAbstractItemModel *sourceModel) |
| QAbstractItemModel * | sourceModel() const |
| virtual QModelIndex | mapToSource(const QModelIndex &proxyIndex) const |
| virtual QModelIndex | mapFromSource(const QModelIndex &sourceIndex) const |
| virtual QItemSelection | mapSelectionToSource(const QItemSelection &selection) const |
| virtual QItemSelection | mapSelectionFromSource(const QItemSelection &selection) const |
Reimplemented Public Functions
| QVariant | data(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const |
| QVariant | headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const |
| QMap<int, QVariant> | itemData(const QModelIndex &index) const |
| Qt::ItemFlags | flags(const QModelIndex &index) const |
| bool | setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) |
| bool | setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles) |
| bool | setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) |
| bool | clearItemData(const QModelIndex &index) |
| QModelIndex | buddy(const QModelIndex &index) const |
| bool | canFetchMore(const QModelIndex &parent) const |
| void | fetchMore(const QModelIndex &parent) |
| void | sort(int column, Qt::SortOrder order = Qt::AscendingOrder) |
| QSize | span(const QModelIndex &index) const |
| bool | hasChildren(const QModelIndex &parent = QModelIndex()) const |
| QModelIndex | sibling(int row, int column, const QModelIndex &idx) const |
| QMimeData * | mimeData(const QModelIndexList &indexes) const |
| bool | canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const |
| bool | dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) |
| QStringList | mimeTypes() const |
| Qt::DropActions | supportedDragActions() const |
| Qt::DropActions | supportedDropActions() const |
| QHash<int, QByteArray> | roleNames() const |
Public Slots
Signals
| void | sourceModelChanged() |
Protected Functions
| QModelIndex | createSourceIndex(int row, int col, void *internalPtr) const |
Detailed Description
A proxy model presents the items of a source model in another form. Subclasses implement mapToSource() and mapFromSource(); the data, header, flag and MIME functions are forwarded through them.
See also QIdentityProxyModel and QSortFilterProxyModel.
Differences from Qt
sourceModelChanged() has no QPrivateSignal argument, and there are no bindable properties.
Member Function Documentation
QAbstractProxyModel::QAbstractProxyModel(QObject *parent = nullptr)
Constructs a proxy model with the given parent and no source model.
QAbstractProxyModel::~QAbstractProxyModel()
Destroys the proxy model.
QModelIndex QAbstractProxyModel::buddy(const QModelIndex &index) const
Reimplements QAbstractItemModel::buddy().
Returns the proxy index of the buddy of the source item of index.
bool QAbstractProxyModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
Reimplements QAbstractItemModel::canDropMimeData().
Returns whether the source model accepts data dropped with action at the source position of row and column under parent.
bool QAbstractProxyModel::canFetchMore(const QModelIndex &parent) const
Reimplements QAbstractItemModel::canFetchMore().
Returns whether the source model can fetch more items under the source item of parent.
bool QAbstractProxyModel::clearItemData(const QModelIndex &index)
Reimplements QAbstractItemModel::clearItemData().
Clears the item data of the source item of index.
QModelIndex QAbstractProxyModel::createSourceIndex(int row, int col, void *internalPtr) const
Creates an index of the source model for row and col that stores internalPtr, for proxies whose indexes mirror those of the source.
This function was introduced in 5.8.
QVariant QAbstractProxyModel::data(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const
Reimplements QAbstractItemModel::data().
Returns the data of the source item of proxyIndex for role.
bool QAbstractProxyModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
Reimplements QAbstractItemModel::dropMimeData().
Drops data with action into the source model at the source position of row and column under parent.
void QAbstractProxyModel::fetchMore(const QModelIndex &parent)
Reimplements QAbstractItemModel::fetchMore().
Fetches more items under the source item of parent.
Qt::ItemFlags QAbstractProxyModel::flags(const QModelIndex &index) const
Reimplements QAbstractItemModel::flags().
Returns the flags of the source item of index.
bool QAbstractProxyModel::hasChildren(const QModelIndex &parent = QModelIndex()) const
Reimplements QAbstractItemModel::hasChildren().
Returns whether the source item of parent has children.
QVariant QAbstractProxyModel::headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const
Reimplements QAbstractItemModel::headerData().
Returns the header data of section in orientation for role, taken from the source section that the proxy section shows.
QMap<int, QVariant> QAbstractProxyModel::itemData(const QModelIndex &index) const
Reimplements QAbstractItemModel::itemData().
Returns the item data of the source item of index.
QModelIndex QAbstractProxyModel::mapFromSource(const QModelIndex &sourceIndex) const
Returns the proxy index of the source item at sourceIndex, or an invalid index if the proxy does not show it.
QItemSelection QAbstractProxyModel::mapSelectionFromSource(const QItemSelection &selection) const
Returns selection with each range mapped from the source model.
QItemSelection QAbstractProxyModel::mapSelectionToSource(const QItemSelection &selection) const
Returns selection with each range mapped to the source model.
QModelIndex QAbstractProxyModel::mapToSource(const QModelIndex &proxyIndex) const
Returns the source index of the item at proxyIndex, or an invalid index.
QMimeData * QAbstractProxyModel::mimeData(const QModelIndexList &indexes) const
Reimplements QAbstractItemModel::mimeData().
Returns the MIME data of the source items of indexes.
QStringList QAbstractProxyModel::mimeTypes() const
Reimplements QAbstractItemModel::mimeTypes().
Returns the MIME types of the source model.
void QAbstractProxyModel::revert()
Reimplements QAbstractItemModel::revert().
Calls revert() on the source model.
QHash<int, QByteArray> QAbstractProxyModel::roleNames() const
Reimplements QAbstractItemModel::roleNames().
Returns the role names of the source model.
bool QAbstractProxyModel::setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole)
Reimplements QAbstractItemModel::setData().
Sets the data of the source item of index for role to value.
bool QAbstractProxyModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole)
Reimplements QAbstractItemModel::setHeaderData().
Sets the header data of the source section shown as section in orientation for role to value.
bool QAbstractProxyModel::setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles)
Reimplements QAbstractItemModel::setItemData().
Sets the data of the source item of index for the roles in roles.
void QAbstractProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
Sets the source model to sourceModel and emits sourceModelChanged(). Subclasses that reimplement it connect to the signals of the source and call this implementation. When the source model is destroyed, the proxy is left without one.
See also sourceModel().
QModelIndex QAbstractProxyModel::sibling(int row, int column, const QModelIndex &idx) const
Reimplements QAbstractItemModel::sibling().
Returns the index at row and column next to idx.
void QAbstractProxyModel::sort(int column, Qt::SortOrder order = Qt::AscendingOrder)
Reimplements QAbstractItemModel::sort().
Sorts the source model by column in order.
QAbstractItemModel * QAbstractProxyModel::sourceModel() const
Returns the source model, or nullptr.
void QAbstractProxyModel::sourceModelChanged()
This signal is emitted when the source model changes.
This function was introduced in 5.1.
QSize QAbstractProxyModel::span(const QModelIndex &index) const
Reimplements QAbstractItemModel::span().
Returns the span of the source item of index.
bool QAbstractProxyModel::submit()
Reimplements QAbstractItemModel::submit().
Calls submit() on the source model.
Qt::DropActions QAbstractProxyModel::supportedDragActions() const
Reimplements QAbstractItemModel::supportedDragActions().
Returns the drag actions of the source model.
Qt::DropActions QAbstractProxyModel::supportedDropActions() const
Reimplements QAbstractItemModel::supportedDropActions().
Returns the drop actions of the source model.