QIdentityProxyModel¶
The QIdentityProxyModel
class proxies its source model unmodified. More…
Detailed Description¶
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 cannot be modified.
class DateFormatProxyModel(QIdentityProxyModel): # ... def setDateFormatString(formatString): m_formatString = formatString data = QVariant(QModelIndex index, int role) if (role != Qt.DisplayRole) return QIdentityProxyModel.data(index, role) dateTime = sourceModel().data(SourceClass::DateRole).toDateTime() return dateTime.toString(m_formatString) # private m_formatString = QString()
- class PySide6.QtCore.QIdentityProxyModel([parent=None])¶
- Parameters
parent –
PySide6.QtCore.QObject
Constructs an identity model with the given parent
.
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.