QIdentityProxyModel class proxies its source model unmodified. More…
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])#
Constructs an identity model with the given