<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html><head><title>QIdentityProxyModel Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } td.postheader { font-family: sans-serif } tr.address { font-family: sans-serif } body { background: #ffffff; color: black; } </style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QIdentityProxyModel Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QIdentityProxyModel class proxies its source model unmodified <a href="#details">More...</a></p> <p>Inherits <a href="qabstractproxymodel.html">QAbstractProxyModel</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qidentityproxymodel.html#QIdentityProxyModel">__init__</a></b> (<i>self</i>, QObject <i>parent</i> = None)</li><li><div class="fn" />int <b><a href="qidentityproxymodel.html#columnCount">columnCount</a></b> (<i>self</i>, QModelIndex <i>parent</i> = QModelIndex())</li><li><div class="fn" />bool <b><a href="qidentityproxymodel.html#dropMimeData">dropMimeData</a></b> (<i>self</i>, QMimeData <i>data</i>, Qt.DropAction <i>action</i>, int <i>row</i>, int <i>column</i>, QModelIndex <i>parent</i>)</li><li><div class="fn" />QModelIndex <b><a href="qidentityproxymodel.html#index">index</a></b> (<i>self</i>, int <i>row</i>, int <i>column</i>, QModelIndex <i>parent</i> = QModelIndex())</li><li><div class="fn" />bool <b><a href="qidentityproxymodel.html#insertColumns">insertColumns</a></b> (<i>self</i>, int <i>column</i>, int <i>count</i>, QModelIndex <i>parent</i> = QModelIndex())</li><li><div class="fn" />bool <b><a href="qidentityproxymodel.html#insertRows">insertRows</a></b> (<i>self</i>, int <i>row</i>, int <i>count</i>, QModelIndex <i>parent</i> = QModelIndex())</li><li><div class="fn" />QModelIndex <b><a href="qidentityproxymodel.html#mapFromSource">mapFromSource</a></b> (<i>self</i>, QModelIndex <i>sourceIndex</i>)</li><li><div class="fn" />QItemSelection <b><a href="qidentityproxymodel.html#mapSelectionFromSource">mapSelectionFromSource</a></b> (<i>self</i>, QItemSelection <i>selection</i>)</li><li><div class="fn" />QItemSelection <b><a href="qidentityproxymodel.html#mapSelectionToSource">mapSelectionToSource</a></b> (<i>self</i>, QItemSelection <i>selection</i>)</li><li><div class="fn" />QModelIndex <b><a href="qidentityproxymodel.html#mapToSource">mapToSource</a></b> (<i>self</i>, QModelIndex <i>proxyIndex</i>)</li><li><div class="fn" />list-of-QModelIndex <b><a href="qidentityproxymodel.html#match">match</a></b> (<i>self</i>, QModelIndex <i>start</i>, int <i>role</i>, QVariant <i>value</i>, int <i>hits</i> = 1, Qt.MatchFlags <i>flags</i> = Qt.MatchStartsWith|Qt.MatchWrap)</li><li><div class="fn" />QModelIndex <b><a href="qidentityproxymodel.html#parent">parent</a></b> (<i>self</i>, QModelIndex <i>child</i>)</li><li><div class="fn" />bool <b><a href="qidentityproxymodel.html#removeColumns">removeColumns</a></b> (<i>self</i>, int <i>column</i>, int <i>count</i>, QModelIndex <i>parent</i> = QModelIndex())</li><li><div class="fn" />bool <b><a href="qidentityproxymodel.html#removeRows">removeRows</a></b> (<i>self</i>, int <i>row</i>, int <i>count</i>, QModelIndex <i>parent</i> = QModelIndex())</li><li><div class="fn" />int <b><a href="qidentityproxymodel.html#rowCount">rowCount</a></b> (<i>self</i>, QModelIndex <i>parent</i> = QModelIndex())</li><li><div class="fn" /><b><a href="qidentityproxymodel.html#setSourceModel">setSourceModel</a></b> (<i>self</i>, QAbstractItemModel <i>sourceModel</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QIdentityProxyModel class proxies its source model unmodified</p> <p>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.</p> <p>Because it does no sorting or filtering, this class is most suitable to proxy models which transform the <a href="qabstractproxymodel.html#data">data</a>() 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.</p> <p>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.</p> <pre class="cpp"> <span class="keyword">class</span> DateFormatProxyModel : <span class="keyword">public</span> <span class="type">QIdentityProxyModel</span> { <span class="comment">// ...</span> <span class="type">void</span> setDateFormatString(<span class="keyword">const</span> <span class="type"><a href="qstring.html">QString</a></span> <span class="operator">&</span>formatString) { m_formatString <span class="operator">=</span> formatString; } <span class="type"><a href="qvariant.html">QVariant</a></span> data(<span class="keyword">const</span> <span class="type"><a href="qmodelindex.html">QModelIndex</a></span> <span class="operator">&</span>index<span class="operator">,</span> <span class="type">int</span> role) { <span class="keyword">if</span> (role <span class="operator">!</span><span class="operator">=</span> <span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>DisplayRole) <span class="keyword">return</span> <span class="type">QIdentityProxyModel</span><span class="operator">.</span>data(index<span class="operator">,</span> role); <span class="keyword">const</span> <span class="type"><a href="qdatetime.html">QDateTime</a></span> dateTime <span class="operator">=</span> sourceModel()<span class="operator">-</span><span class="operator">></span>data(SourceClass<span class="operator">.</span>DateRole)<span class="operator">.</span>toDateTime(); <span class="keyword">return</span> dateTime<span class="operator">.</span>toString(m_formatString); } <span class="keyword">private</span>: <span class="type"><a href="qstring.html">QString</a></span> m_formatString; }; </pre><hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QIdentityProxyModel" />QIdentityProxyModel.__init__ (<i>self</i>, <a href="qobject.html">QObject</a> <i>parent</i> = None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs an identity model with the given <i>parent</i>.</p> <h3 class="fn"><a name="columnCount" />int QIdentityProxyModel.columnCount (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>parent</i> = QModelIndex())</h3><p>Reimplemented from <a href="qabstractitemmodel.html#columnCount">QAbstractItemModel.columnCount</a>().</p> <h3 class="fn"><a name="dropMimeData" />bool QIdentityProxyModel.dropMimeData (<i>self</i>, <a href="qmimedata.html">QMimeData</a> <i>data</i>, <a href="qt.html#DropAction-enum">Qt.DropAction</a> <i>action</i>, int <i>row</i>, int <i>column</i>, <a href="qmodelindex.html">QModelIndex</a> <i>parent</i>)</h3><p>Reimplemented from <a href="qabstractitemmodel.html#dropMimeData">QAbstractItemModel.dropMimeData</a>().</p> <h3 class="fn"><a name="index" /><a href="qmodelindex.html">QModelIndex</a> QIdentityProxyModel.index (<i>self</i>, int <i>row</i>, int <i>column</i>, <a href="qmodelindex.html">QModelIndex</a> <i>parent</i> = QModelIndex())</h3><p>Reimplemented from <a href="qabstractitemmodel.html#index">QAbstractItemModel.index</a>().</p> <h3 class="fn"><a name="insertColumns" />bool QIdentityProxyModel.insertColumns (<i>self</i>, int <i>column</i>, int <i>count</i>, <a href="qmodelindex.html">QModelIndex</a> <i>parent</i> = QModelIndex())</h3><p>Reimplemented from <a href="qabstractitemmodel.html#insertColumns">QAbstractItemModel.insertColumns</a>().</p> <h3 class="fn"><a name="insertRows" />bool QIdentityProxyModel.insertRows (<i>self</i>, int <i>row</i>, int <i>count</i>, <a href="qmodelindex.html">QModelIndex</a> <i>parent</i> = QModelIndex())</h3><p>Reimplemented from <a href="qabstractitemmodel.html#insertRows">QAbstractItemModel.insertRows</a>().</p> <h3 class="fn"><a name="mapFromSource" /><a href="qmodelindex.html">QModelIndex</a> QIdentityProxyModel.mapFromSource (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>sourceIndex</i>)</h3><p>Reimplemented from <a href="qabstractproxymodel.html#mapFromSource">QAbstractProxyModel.mapFromSource</a>().</p> <h3 class="fn"><a name="mapSelectionFromSource" /><a href="qitemselection.html">QItemSelection</a> QIdentityProxyModel.mapSelectionFromSource (<i>self</i>, <a href="qitemselection.html">QItemSelection</a> <i>selection</i>)</h3><p>Reimplemented from <a href="qabstractproxymodel.html#mapSelectionFromSource">QAbstractProxyModel.mapSelectionFromSource</a>().</p> <h3 class="fn"><a name="mapSelectionToSource" /><a href="qitemselection.html">QItemSelection</a> QIdentityProxyModel.mapSelectionToSource (<i>self</i>, <a href="qitemselection.html">QItemSelection</a> <i>selection</i>)</h3><p>Reimplemented from <a href="qabstractproxymodel.html#mapSelectionToSource">QAbstractProxyModel.mapSelectionToSource</a>().</p> <h3 class="fn"><a name="mapToSource" /><a href="qmodelindex.html">QModelIndex</a> QIdentityProxyModel.mapToSource (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>proxyIndex</i>)</h3><p>Reimplemented from <a href="qabstractproxymodel.html#mapToSource">QAbstractProxyModel.mapToSource</a>().</p> <h3 class="fn"><a name="match" />list-of-QModelIndex QIdentityProxyModel.match (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>start</i>, int <i>role</i>, QVariant <i>value</i>, int <i>hits</i> = 1, <a href="qt-matchflags.html">Qt.MatchFlags</a> <i>flags</i> = Qt.MatchStartsWith|Qt.MatchWrap)</h3><p>Reimplemented from <a href="qabstractitemmodel.html#match">QAbstractItemModel.match</a>().</p> <h3 class="fn"><a name="parent" /><a href="qmodelindex.html">QModelIndex</a> QIdentityProxyModel.parent (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>child</i>)</h3><p>Reimplemented from <a href="qabstractitemmodel.html#parent">QAbstractItemModel.parent</a>().</p> <h3 class="fn"><a name="removeColumns" />bool QIdentityProxyModel.removeColumns (<i>self</i>, int <i>column</i>, int <i>count</i>, <a href="qmodelindex.html">QModelIndex</a> <i>parent</i> = QModelIndex())</h3><p>Reimplemented from <a href="qabstractitemmodel.html#removeColumns">QAbstractItemModel.removeColumns</a>().</p> <h3 class="fn"><a name="removeRows" />bool QIdentityProxyModel.removeRows (<i>self</i>, int <i>row</i>, int <i>count</i>, <a href="qmodelindex.html">QModelIndex</a> <i>parent</i> = QModelIndex())</h3><p>Reimplemented from <a href="qabstractitemmodel.html#removeRows">QAbstractItemModel.removeRows</a>().</p> <h3 class="fn"><a name="rowCount" />int QIdentityProxyModel.rowCount (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>parent</i> = QModelIndex())</h3><p>Reimplemented from <a href="qabstractitemmodel.html#rowCount">QAbstractItemModel.rowCount</a>().</p> <h3 class="fn"><a name="setSourceModel" />QIdentityProxyModel.setSourceModel (<i>self</i>, <a href="qabstractitemmodel.html">QAbstractItemModel</a> <i>sourceModel</i>)</h3><p>Reimplemented from <a href="qabstractproxymodel.html#setSourceModel">QAbstractProxyModel.setSourceModel</a>().</p> <address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>