PySide6.QtCore.QIdentityProxyModel¶
- class QIdentityProxyModel¶
- The - QIdentityProxyModelclass proxies its source model unmodified. More…- Synopsis¶- Methods¶- 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. - QIdentityProxyModelcan 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) sourceIndex = mapToSource(index) dateTime = sourceModel().data(sourceIndex, SourceClass::DateRole).toDateTime() return dateTime.toString(m_formatString) QMap<int, QVariant> itemData(QModelIndex proxyIndex) override QVariant> map = QIdentityProxyModel.itemData(proxyIndex) map[Qt.DisplayRole] = data(proxyIndex) return map # private m_formatString = QString() - See also - Constructs an identity model with the given - parent.- handleSourceDataChanges()¶
- Return type:
- bool 
 
 - Returns - trueif this proxy model handles the source model data changes, otherwise returns- false.- See also - handleSourceLayoutChanges()¶
- Return type:
- bool 
 
 - Returns - trueif this proxy model handles the source model layout changes, otherwise returns- false.- See also - setHandleSourceDataChanges(b)¶
- Parameters:
- b – bool 
 
 - If - bis- true, this proxy model will handle the source model data changes (by connecting to- QAbstractItemModel::dataChangedsignal).- The default is for this proxy model to handle the source model data changes. - In sub-classes of - QIdentityProxyModel, it may be useful to set this to- falseif you need to specially handle the source model data changes.- Note - Calling this method will only have an effect after calling - setSourceModel().- See also - setHandleSourceLayoutChanges(b)¶
- Parameters:
- b – bool 
 
 - If - bis- true, this proxy model will handle the source model layout changes (by connecting to- QAbstractItemModel::layoutAboutToBeChangedand- QAbstractItemModel::layoutChangedsignals).- The default is for this proxy model to handle the source model layout changes. - In sub-classes of - QIdentityProxyModel, it may be useful to set this to- falseif you need to specially handle the source model layout changes.- Note - Calling this method will only have an effect after calling - setSourceModel().- See also