QIdentityProxyModel#
The QIdentityProxyModel
class proxies its source model unmodified. More…
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description#
Warning
This section contains snippets that were automatically translated from C++ to Python and may contain errors.
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 QVariant data(QModelIndex index, int role) override 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
.