6.0.0-rc4Source

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>
CMaketarget_link_libraries(app PRIVATE Nt::Core)
ModuleNt Core C++ Classes
Since4.1
InheritsQAbstractItemModel
Inherited byQIdentityProxyModel, QSortFilterProxyModel, QTransposeProxyModel

List of all members, including inherited members

Public Functions

QAbstractProxyModel(QObject *parent = nullptr)
~QAbstractProxyModel()
virtual voidsetSourceModel(QAbstractItemModel *sourceModel)
QAbstractItemModel *sourceModel() const
virtual QModelIndexmapToSource(const QModelIndex &proxyIndex) const
virtual QModelIndexmapFromSource(const QModelIndex &sourceIndex) const
virtual QItemSelectionmapSelectionToSource(const QItemSelection &selection) const
virtual QItemSelectionmapSelectionFromSource(const QItemSelection &selection) const

Reimplemented Public Functions

QVariantdata(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const
QVariantheaderData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const
QMap<int, QVariant>itemData(const QModelIndex &index) const
Qt::ItemFlagsflags(const QModelIndex &index) const
boolsetData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole)
boolsetItemData(const QModelIndex &index, const QMap<int, QVariant> &roles)
boolsetHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole)
boolclearItemData(const QModelIndex &index)
QModelIndexbuddy(const QModelIndex &index) const
boolcanFetchMore(const QModelIndex &parent) const
voidfetchMore(const QModelIndex &parent)
voidsort(int column, Qt::SortOrder order = Qt::AscendingOrder)
QSizespan(const QModelIndex &index) const
boolhasChildren(const QModelIndex &parent = QModelIndex()) const
QModelIndexsibling(int row, int column, const QModelIndex &idx) const
QMimeData *mimeData(const QModelIndexList &indexes) const
boolcanDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
booldropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
QStringListmimeTypes() const
Qt::DropActionssupportedDragActions() const
Qt::DropActionssupportedDropActions() const
QHash<int, QByteArray>roleNames() const

Public Slots

boolsubmit()
voidrevert()

Signals

Protected Functions

QModelIndexcreateSourceIndex(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

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

Constructs a proxy model with the given parent and no source model.

[override] QAbstractProxyModel::~QAbstractProxyModel()

Destroys the proxy model.

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

Reimplements QAbstractItemModel::buddy().

Returns the proxy index of the buddy of the source item of index.

[override] 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.

[override] 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.

[override] bool QAbstractProxyModel::clearItemData(const QModelIndex &index)

Reimplements QAbstractItemModel::clearItemData().

Clears the item data of the source item of index.

[protected] 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.

[override] 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.

[override] 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.

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

Reimplements QAbstractItemModel::fetchMore().

Fetches more items under the source item of parent.

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

Reimplements QAbstractItemModel::flags().

Returns the flags of the source item of index.

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

Reimplements QAbstractItemModel::hasChildren().

Returns whether the source item of parent has children.

[override] 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.

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

Reimplements QAbstractItemModel::itemData().

Returns the item data of the source item of index.

[virtual] 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.

[virtual] QItemSelection QAbstractProxyModel::mapSelectionFromSource(const QItemSelection &selection) const

Returns selection with each range mapped from the source model.

[virtual] QItemSelection QAbstractProxyModel::mapSelectionToSource(const QItemSelection &selection) const

Returns selection with each range mapped to the source model.

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

Returns the source index of the item at proxyIndex, or an invalid index.

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

Reimplements QAbstractItemModel::mimeData().

Returns the MIME data of the source items of indexes.

[override] QStringList QAbstractProxyModel::mimeTypes() const

Reimplements QAbstractItemModel::mimeTypes().

Returns the MIME types of the source model.

[slot, override] void QAbstractProxyModel::revert()

Reimplements QAbstractItemModel::revert().

Calls revert() on the source model.

[override] QHash<int, QByteArray> QAbstractProxyModel::roleNames() const

Reimplements QAbstractItemModel::roleNames().

Returns the role names of the source model.

[override] 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.

[override] 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.

[override] 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.

[virtual] 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().

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

Reimplements QAbstractItemModel::sibling().

Returns the index at row and column next to idx.

[override] 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.

[signal] void QAbstractProxyModel::sourceModelChanged()

This signal is emitted when the source model changes.

This function was introduced in 5.1.

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

Reimplements QAbstractItemModel::span().

Returns the span of the source item of index.

[slot, override] bool QAbstractProxyModel::submit()

Reimplements QAbstractItemModel::submit().

Calls submit() on the source model.

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

Reimplements QAbstractItemModel::supportedDragActions().

Returns the drag actions of the source model.

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

Reimplements QAbstractItemModel::supportedDropActions().

Returns the drop actions of the source model.