QIdentityProxyModel Class
The QIdentityProxyModel class proxies its source model unmodified 更多...
头文件: | #include <QIdentityProxyModel> |
qmake: | QT += core |
开始支持版本: | Qt 4.8 |
基类: | QAbstractProxyModel |
公有函数
QIdentityProxyModel(QObject *parent = Q_NULLPTR) | |
~QIdentityProxyModel() |
重新实现的公有函数
virtual int | columnCount(const QModelIndex &parent = QModelIndex()) const |
virtual bool | dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) |
virtual QVariant | headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const |
virtual QModelIndex | index(int row, int column, const QModelIndex &parent = QModelIndex()) const |
virtual bool | insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) |
virtual bool | insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) |
virtual QModelIndex | mapFromSource(const QModelIndex &sourceIndex) const |
virtual QItemSelection | mapSelectionFromSource(const QItemSelection &selection) const |
virtual QItemSelection | mapSelectionToSource(const QItemSelection &selection) const |
virtual QModelIndex | mapToSource(const QModelIndex &proxyIndex) const |
virtual QModelIndexList | match(const QModelIndex &start, int role, const QVariant &value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap )) const |
virtual QModelIndex | parent(const QModelIndex &child) const |
virtual bool | removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) |
virtual bool | removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) |
virtual int | rowCount(const QModelIndex &parent = QModelIndex()) const |
virtual void | setSourceModel(QAbstractItemModel *newSourceModel) |
virtual QModelIndex | sibling(int row, int column, const QModelIndex &idx) const |
- 28 个公有函数继承自 QAbstractProxyModel
- 39 个公有函数继承自 QAbstractItemModel
- 32 个公有函数继承自 QObject
其他继承的成员
- 1 个属性继承自 QAbstractProxyModel
- 1 个属性继承自 QObject
- 2 个公有槽函数继承自 QAbstractItemModel
- 1 个公有槽函数继承自 QObject
- 1 个信号继承自 QAbstractProxyModel
- 18 个信号继承自 QAbstractItemModel
- 2 个信号继承自 QObject
- 11 个静态公有成员继承自 QObject
- 19 个受保护的函数继承自 QAbstractItemModel
- 9 个受保护的函数继承自 QObject
- 1 个受保护的槽函数继承自 QAbstractProxyModel
- 1 个受保护的槽函数继承自 QAbstractItemModel
详细描述
The QIdentityProxyModel class proxies its source model unmodified
QIdentityProxyModel can be used to forward the structure of a source model exactly, with no sorting, filtering or other transformation. This is similar in concept to an identity matrix where A.I = A.
Because it does no sorting or filtering, this class is most suitable to proxy models which transform the data() of the source model. For example, a proxy model could be created to define the font used, or the background colour, or the tooltip etc. This removes the need to implement all data handling in the same class that creates the structure of the model, and can also be used to create re-usable components.
This also provides a way to change the data in the case where a source model is supplied by a third party which can not be modified.
class DateFormatProxyModel : public QIdentityProxyModel { // ... void setDateFormatString(const QString &formatString) { m_formatString = formatString; } QVariant data(const QModelIndex &index, int role) const { if (role != Qt::DisplayRole) return QIdentityProxyModel::data(index, role); const QDateTime dateTime = sourceModel()->data(SourceClass::DateRole).toDateTime(); return dateTime.toString(m_formatString); } private: QString m_formatString; };
参见 QAbstractProxyModel, Model/View Programming, and QAbstractItemModel.
成员函数
QIdentityProxyModel::QIdentityProxyModel(QObject *parent = Q_NULLPTR)
Constructs an identity model with the given parent.
QIdentityProxyModel::~QIdentityProxyModel()
Destroys this identity model.
[virtual]
int QIdentityProxyModel::columnCount(const QModelIndex &parent = QModelIndex()) const
Reimplemented from QAbstractItemModel::columnCount().
[virtual]
bool QIdentityProxyModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
Reimplemented from QAbstractItemModel::dropMimeData().
[virtual]
QVariant QIdentityProxyModel::headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const
Reimplemented from QAbstractItemModel::headerData().
[virtual]
QModelIndex QIdentityProxyModel::index(int row, int column, const QModelIndex &parent = QModelIndex()) const
Reimplemented from QAbstractItemModel::index().
[virtual]
bool QIdentityProxyModel::insertColumns(int column, int count, const QModelIndex &parent = QModelIndex())
Reimplemented from QAbstractItemModel::insertColumns().
[virtual]
bool QIdentityProxyModel::insertRows(int row, int count, const QModelIndex &parent = QModelIndex())
Reimplemented from QAbstractItemModel::insertRows().
[virtual]
QModelIndex QIdentityProxyModel::mapFromSource(const QModelIndex &sourceIndex) const
Reimplemented from QAbstractProxyModel::mapFromSource().
[virtual]
QItemSelection QIdentityProxyModel::mapSelectionFromSource(const QItemSelection &selection) const
Reimplemented from QAbstractProxyModel::mapSelectionFromSource().
[virtual]
QItemSelection QIdentityProxyModel::mapSelectionToSource(const QItemSelection &selection) const
Reimplemented from QAbstractProxyModel::mapSelectionToSource().
[virtual]
QModelIndex QIdentityProxyModel::mapToSource(const QModelIndex &proxyIndex) const
Reimplemented from QAbstractProxyModel::mapToSource().
[virtual]
QModelIndexList QIdentityProxyModel::match(const QModelIndex &start, int role, const QVariant &value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap )) const
Reimplemented from QAbstractItemModel::match().
[virtual]
QModelIndex QIdentityProxyModel::parent(const QModelIndex &child) const
Reimplemented from QAbstractItemModel::parent().
[virtual]
bool QIdentityProxyModel::removeColumns(int column, int count, const QModelIndex &parent = QModelIndex())
Reimplemented from QAbstractItemModel::removeColumns().
[virtual]
bool QIdentityProxyModel::removeRows(int row, int count, const QModelIndex &parent = QModelIndex())
Reimplemented from QAbstractItemModel::removeRows().
[virtual]
int QIdentityProxyModel::rowCount(const QModelIndex &parent = QModelIndex()) const
Reimplemented from QAbstractItemModel::rowCount().
[virtual]
void QIdentityProxyModel::setSourceModel(QAbstractItemModel *newSourceModel)
Reimplemented from QAbstractProxyModel::setSourceModel().
[virtual]
QModelIndex QIdentityProxyModel::sibling(int row, int column, const QModelIndex &idx) const
Reimplemented from QAbstractItemModel::sibling().