QIdentityProxyModel Class Reference

[ QtGui module]

The QIdentityProxyModel class proxies its source model unmodified 更多...

继承 QAbstractProxyModel .

方法


详细描述

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)
   {
     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;
 };
			

方法文档编制

QIdentityProxyModel.__init__ ( self , QObject   parent  = None)

parent argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs an identity model with the given parent .

int QIdentityProxyModel.columnCount ( self , QModelIndex   parent  = QModelIndex())

重实现自 QAbstractItemModel.columnCount ().

bool QIdentityProxyModel.dropMimeData ( self , QMimeData   data , Qt.DropAction   action , int  row , int  column , QModelIndex   parent )

重实现自 QAbstractItemModel.dropMimeData ().

QModelIndex QIdentityProxyModel.index ( self , int  row , int  column , QModelIndex   parent  = QModelIndex())

重实现自 QAbstractItemModel.index ().

bool QIdentityProxyModel.insertColumns ( self , int  column , int  count , QModelIndex   parent  = QModelIndex())

重实现自 QAbstractItemModel.insertColumns ().

bool QIdentityProxyModel.insertRows ( self , int  row , int  count , QModelIndex   parent  = QModelIndex())

重实现自 QAbstractItemModel.insertRows ().

QModelIndex QIdentityProxyModel.mapFromSource ( self , QModelIndex   sourceIndex )

重实现自 QAbstractProxyModel.mapFromSource ().

QItemSelection QIdentityProxyModel.mapSelectionFromSource ( self , QItemSelection   selection )

重实现自 QAbstractProxyModel.mapSelectionFromSource ().

QItemSelection QIdentityProxyModel.mapSelectionToSource ( self , QItemSelection   selection )

重实现自 QAbstractProxyModel.mapSelectionToSource ().

QModelIndex QIdentityProxyModel.mapToSource ( self , QModelIndex   proxyIndex )

重实现自 QAbstractProxyModel.mapToSource ().

list-of-QModelIndex QIdentityProxyModel.match ( self , QModelIndex   start , int  role , QVariant  value , int  hits  = 1, Qt.MatchFlags   flags  = Qt.MatchStartsWith|Qt.MatchWrap)

重实现自 QAbstractItemModel.match ().

QModelIndex QIdentityProxyModel.parent ( self , QModelIndex   child )

重实现自 QAbstractItemModel.parent ().

bool QIdentityProxyModel.removeColumns ( self , int  column , int  count , QModelIndex   parent  = QModelIndex())

重实现自 QAbstractItemModel.removeColumns ().

bool QIdentityProxyModel.removeRows ( self , int  row , int  count , QModelIndex   parent  = QModelIndex())

重实现自 QAbstractItemModel.removeRows ().

int QIdentityProxyModel.rowCount ( self , QModelIndex   parent  = QModelIndex())

重实现自 QAbstractItemModel.rowCount ().

QIdentityProxyModel.setSourceModel ( self , QAbstractItemModel   sourceModel )

重实现自 QAbstractProxyModel.setSourceModel ().