1
<?xml version="1.0" encoding="iso-8859-1"?>
3
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/gui/itemviews/qproxymodel.cpp -->
7
<title>Qt 4.0: QProxyModel Class Reference</title>
8
<style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
9
a:link { color: #004faf; text-decoration: none }
10
a:visited { color: #672967; text-decoration: none }
11
td.postheader { font-family: sans-serif }
12
tr.address { font-family: sans-serif }
13
body { background: #ffffff; color: black; }</style>
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
19
<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="mainclasses.html"><font color="#004faf">Main Classes</font></a> · <a href="annotated.html"><font color="#004faf">Annotated</font></a> · <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td>
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QProxyModel Class Reference</h1>
21
<p>The QProxyModel class provides support for filtering and sorting data that is passed between another model and a view. <a href="#details">More...</a></p>
22
<pre>#include <QProxyModel></pre><p>Part of the <a href="qtgui.html">QtGui</a> module.</p>
23
<p>Inherits <a href="qabstractitemmodel.html">QAbstractItemModel</a>.</p>
25
<li><a href="qproxymodel-members.html">List of all members, including inherited members</a></li>
27
<a name="public-functions"></a>
28
<h3>Public Functions</h3>
30
<li><div class="fn"/><b><a href="qproxymodel.html#QProxyModel">QProxyModel</a></b> ( QObject * <i>parent</i> = 0 )</li>
31
<li><div class="fn"/><b><a href="qproxymodel.html#dtor.QProxyModel">~QProxyModel</a></b> ()</li>
32
<li><div class="fn"/>virtual int <b><a href="qproxymodel.html#columnCount">columnCount</a></b> ( const QModelIndex & <i>parent</i> ) const</li>
33
<li><div class="fn"/>virtual QVariant <b><a href="qproxymodel.html#data">data</a></b> ( const QModelIndex & <i>index</i>, int <i>role</i> ) const</li>
34
<li><div class="fn"/>virtual bool <b><a href="qproxymodel.html#dropMimeData">dropMimeData</a></b> ( const QMimeData * <i>data</i>, Qt::DropAction <i>action</i>, int <i>row</i>, int <i>column</i>, const QModelIndex & <i>parent</i> )</li>
35
<li><div class="fn"/>virtual void <b><a href="qproxymodel.html#fetchMore">fetchMore</a></b> ( const QModelIndex & <i>parent</i> )</li>
36
<li><div class="fn"/>virtual Qt::ItemFlags <b><a href="qproxymodel.html#flags">flags</a></b> ( const QModelIndex & <i>index</i> ) const</li>
37
<li><div class="fn"/>virtual bool <b><a href="qproxymodel.html#hasChildren">hasChildren</a></b> ( const QModelIndex & <i>parent</i> ) const</li>
38
<li><div class="fn"/>virtual QVariant <b><a href="qproxymodel.html#headerData">headerData</a></b> ( int <i>section</i>, Qt::Orientation <i>orientation</i>, int <i>role</i> ) const</li>
39
<li><div class="fn"/>virtual QModelIndex <b><a href="qproxymodel.html#index">index</a></b> ( int <i>row</i>, int <i>column</i>, const QModelIndex & <i>parent</i> ) const</li>
40
<li><div class="fn"/>virtual bool <b><a href="qproxymodel.html#insertColumns">insertColumns</a></b> ( int <i>column</i>, int <i>count</i>, const QModelIndex & <i>parent</i> )</li>
41
<li><div class="fn"/>virtual bool <b><a href="qproxymodel.html#insertRows">insertRows</a></b> ( int <i>row</i>, int <i>count</i>, const QModelIndex & <i>parent</i> )</li>
42
<li><div class="fn"/>virtual QModelIndexList <b><a href="qproxymodel.html#match">match</a></b> ( const QModelIndex & <i>start</i>, int <i>role</i>, const QVariant & <i>value</i>, int <i>hits</i>, Qt::MatchFlags <i>flags</i> ) const</li>
43
<li><div class="fn"/>virtual QMimeData * <b><a href="qproxymodel.html#mimeData">mimeData</a></b> ( const QModelIndexList & <i>indexes</i> ) const</li>
44
<li><div class="fn"/>virtual QStringList <b><a href="qproxymodel.html#mimeTypes">mimeTypes</a></b> () const</li>
45
<li><div class="fn"/>QAbstractItemModel * <b><a href="qproxymodel.html#model">model</a></b> () const</li>
46
<li><div class="fn"/>virtual QModelIndex <b><a href="qproxymodel.html#parent">parent</a></b> ( const QModelIndex & <i>child</i> ) const</li>
47
<li><div class="fn"/>virtual void <b><a href="qproxymodel.html#revert">revert</a></b> ()</li>
48
<li><div class="fn"/>virtual int <b><a href="qproxymodel.html#rowCount">rowCount</a></b> ( const QModelIndex & <i>parent</i> ) const</li>
49
<li><div class="fn"/>virtual bool <b><a href="qproxymodel.html#setData">setData</a></b> ( const QModelIndex & <i>index</i>, const QVariant & <i>value</i>, int <i>role</i> )</li>
50
<li><div class="fn"/>virtual bool <b><a href="qproxymodel.html#setHeaderData">setHeaderData</a></b> ( int <i>section</i>, Qt::Orientation <i>orientation</i>, const QVariant & <i>value</i>, int <i>role</i> )</li>
51
<li><div class="fn"/>virtual void <b><a href="qproxymodel.html#setModel">setModel</a></b> ( QAbstractItemModel * <i>model</i> )</li>
52
<li><div class="fn"/>virtual void <b><a href="qproxymodel.html#sort">sort</a></b> ( int <i>column</i>, Qt::SortOrder <i>order</i> )</li>
53
<li><div class="fn"/>virtual QSize <b><a href="qproxymodel.html#span">span</a></b> ( const QModelIndex & <i>index</i> ) const</li>
54
<li><div class="fn"/>virtual bool <b><a href="qproxymodel.html#submit">submit</a></b> ()</li>
55
<li><div class="fn"/>virtual Qt::DropActions <b><a href="qproxymodel.html#supportedDropActions">supportedDropActions</a></b> () const</li>
58
<li><div class="fn"/>32 public functions inherited from <a href="qabstractitemmodel.html#public-functions">QAbstractItemModel</a></li>
59
<li><div class="fn"/>28 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
61
<h3>Additional Inherited Members</h3>
63
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
64
<li><div class="fn"/>2 public slots inherited from <a href="qabstractitemmodel.html#public-slots">QAbstractItemModel</a></li>
65
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
66
<li><div class="fn"/>3 signals inherited from <a href="qabstractitemmodel.html#signals">QAbstractItemModel</a></li>
67
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
68
<li><div class="fn"/>4 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
69
<li><div class="fn"/>12 protected functions inherited from <a href="qabstractitemmodel.html#protected-functions">QAbstractItemModel</a></li>
70
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
72
<a name="details"></a>
74
<h2>Detailed Description</h2>
75
<p>The QProxyModel class provides support for filtering and sorting data that is passed between another model and a view.</p>
76
<p>Proxy models provide a standard model interface</p>
77
<p>See also <a href="model-view-programming.html">Model/View Programming</a> and <a href="qabstractitemmodel.html">QAbstractItemModel</a>.</p>
79
<h2>Member Function Documentation</h2>
80
<h3 class="fn"><a name="QProxyModel"></a>QProxyModel::QProxyModel ( <a href="qobject.html">QObject</a> * <i>parent</i> = 0 )</h3>
81
<p>Constructs a proxy model with the given <i>parent</i>.</p>
82
<h3 class="fn"><a name="dtor.QProxyModel"></a>QProxyModel::~QProxyModel ()</h3>
83
<p>Destroys the proxy model.</p>
84
<h3 class="fn"><a name="columnCount"></a>int QProxyModel::columnCount ( const <a href="qmodelindex.html">QModelIndex</a> & <i>parent</i> ) const <tt> [virtual]</tt></h3>
85
<p>Returns the number of columns for the given <i>parent</i>.</p>
86
<p>Reimplemented from <a href="qabstractitemmodel.html#columnCount">QAbstractItemModel</a>.</p>
87
<p>See also <a href="qabstractitemmodel.html#columnCount">QAbstractItemModel::columnCount</a>().</p>
88
<h3 class="fn"><a name="data"></a><a href="qvariant.html">QVariant</a> QProxyModel::data ( const <a href="qmodelindex.html">QModelIndex</a> & <i>index</i>, int <i>role</i> ) const <tt> [virtual]</tt></h3>
89
<p>Returns the data stored in the item with the given <i>index</i> under the specified <i>role</i>.</p>
90
<p>Reimplemented from <a href="qabstractitemmodel.html#data">QAbstractItemModel</a>.</p>
91
<h3 class="fn"><a name="dropMimeData"></a>bool QProxyModel::dropMimeData ( const <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>, const <a href="qmodelindex.html">QModelIndex</a> & <i>parent</i> ) <tt> [virtual]</tt></h3>
92
<p>Returns true if the model accepts the <i>data</i> dropped onto an attached view for the specified <i>action</i>; otherwise returns false.</p>
93
<p>The <i>parent</i>, <i>row</i>, and <i>column</i> details can be used to control which MIME types are acceptable to different parts of a model when received via the drag and drop system.</p>
94
<p>Reimplemented from <a href="qabstractitemmodel.html#dropMimeData">QAbstractItemModel</a>.</p>
95
<h3 class="fn"><a name="fetchMore"></a>void QProxyModel::fetchMore ( const <a href="qmodelindex.html">QModelIndex</a> & <i>parent</i> ) <tt> [virtual]</tt></h3>
96
<p>Fetches more child items of the given <i>parent</i>. This function is used by views to tell the model that they can display more data than the model has provided.</p>
97
<p>Reimplemented from <a href="qabstractitemmodel.html#fetchMore">QAbstractItemModel</a>.</p>
98
<p>See also <a href="qabstractitemmodel.html#fetchMore">QAbstractItemModel::fetchMore</a>().</p>
99
<h3 class="fn"><a name="flags"></a><a href="qt.html#ItemFlag-enum">Qt::ItemFlags</a> QProxyModel::flags ( const <a href="qmodelindex.html">QModelIndex</a> & <i>index</i> ) const <tt> [virtual]</tt></h3>
100
<p>Returns the item flags for the given <i>index</i>.</p>
101
<p>Reimplemented from <a href="qabstractitemmodel.html#flags">QAbstractItemModel</a>.</p>
102
<h3 class="fn"><a name="hasChildren"></a>bool QProxyModel::hasChildren ( const <a href="qmodelindex.html">QModelIndex</a> & <i>parent</i> ) const <tt> [virtual]</tt></h3>
103
<p>Returns true if the item corresponding to the <i>parent</i> index has child items; otherwise returns false.</p>
104
<p>Reimplemented from <a href="qabstractitemmodel.html#hasChildren">QAbstractItemModel</a>.</p>
105
<p>See also <a href="qabstractitemmodel.html#hasChildren">QAbstractItemModel::hasChildren</a>().</p>
106
<h3 class="fn"><a name="headerData"></a><a href="qvariant.html">QVariant</a> QProxyModel::headerData ( int <i>section</i>, <a href="qt.html#Orientation-enum">Qt::Orientation</a> <i>orientation</i>, int <i>role</i> ) const <tt> [virtual]</tt></h3>
107
<p>Returns the data stored in the <i>section</i> of the header with specified <i>orientation</i> under the given <i>role</i>.</p>
108
<p>Reimplemented from <a href="qabstractitemmodel.html#headerData">QAbstractItemModel</a>.</p>
109
<h3 class="fn"><a name="index"></a><a href="qmodelindex.html">QModelIndex</a> QProxyModel::index ( int <i>row</i>, int <i>column</i>, const <a href="qmodelindex.html">QModelIndex</a> & <i>parent</i> ) const <tt> [virtual]</tt></h3>
110
<p>Returns the model index with the given <i>row</i>, <i>column</i>, and <i>parent</i>.</p>
111
<p>Reimplemented from <a href="qabstractitemmodel.html#index">QAbstractItemModel</a>.</p>
112
<p>See also <a href="qabstractitemmodel.html#index">QAbstractItemModel::index</a>().</p>
113
<h3 class="fn"><a name="insertColumns"></a>bool QProxyModel::insertColumns ( int <i>column</i>, int <i>count</i>, const <a href="qmodelindex.html">QModelIndex</a> & <i>parent</i> ) <tt> [virtual]</tt></h3>
114
<p>Inserts <i>count</i> columns into the model, creating new items as children of the given <i>parent</i>. The new columns are inserted before the <i>column</i> specified. If the <i>parent</i> item has no children, a single row is created to contain the required number of columns.</p>
115
<p>Returns true if the columns were successfully inserted; otherwise returns false.</p>
116
<p>Reimplemented from <a href="qabstractitemmodel.html#insertColumns">QAbstractItemModel</a>.</p>
117
<p>See also <a href="qabstractitemmodel.html#insertColumns">QAbstractItemModel::insertColumns</a>().</p>
118
<h3 class="fn"><a name="insertRows"></a>bool QProxyModel::insertRows ( int <i>row</i>, int <i>count</i>, const <a href="qmodelindex.html">QModelIndex</a> & <i>parent</i> ) <tt> [virtual]</tt></h3>
119
<p>Inserts <i>count</i> rows into the model, creating new items as children of the given <i>parent</i>. The new rows are inserted before the <i>row</i> specified. If the <i>parent</i> item has no children, a single column is created to contain the required number of rows.</p>
120
<p>Returns true if the rows were successfully inserted; otherwise returns false.</p>
121
<p>Reimplemented from <a href="qabstractitemmodel.html#insertRows">QAbstractItemModel</a>.</p>
122
<p>See also <a href="qabstractitemmodel.html#insertRows">QAbstractItemModel::insertRows</a>().</p>
123
<h3 class="fn"><a name="match"></a>QModelIndexList QProxyModel::match ( const <a href="qmodelindex.html">QModelIndex</a> & <i>start</i>, int <i>role</i>, const <a href="qvariant.html">QVariant</a> & <i>value</i>, int <i>hits</i>, <a href="qt.html#MatchFlag-enum">Qt::MatchFlags</a> <i>flags</i> ) const <tt> [virtual]</tt></h3>
124
<p>Returns a list of model indexes that each contain the given <i>value</i> for the <i>role</i> specified. The search begins at the <i>start</i> index and is performed according to the specified <i>flags</i>. The search continues until the number of matching data items equals <i>hits</i>, the last row is reached, or the search reaches <i>start</i> again, depending on whether <tt>MatchWrap</tt> is specified in <i>flags</i>.</p>
125
<p>Reimplemented from <a href="qabstractitemmodel.html#match">QAbstractItemModel</a>.</p>
126
<p>See also <a href="qabstractitemmodel.html#match">QAbstractItemModel::match</a>().</p>
127
<h3 class="fn"><a name="mimeData"></a><a href="qmimedata.html">QMimeData</a> * QProxyModel::mimeData ( const QModelIndexList & <i>indexes</i> ) const <tt> [virtual]</tt></h3>
128
<p>Returns MIME data for the specified <i>indexes</i> in the model.</p>
129
<p>Reimplemented from <a href="qabstractitemmodel.html#mimeData">QAbstractItemModel</a>.</p>
130
<h3 class="fn"><a name="mimeTypes"></a><a href="qstringlist.html">QStringList</a> QProxyModel::mimeTypes () const <tt> [virtual]</tt></h3>
131
<p>Returns a list of MIME types that are supported by the model.</p>
132
<p>Reimplemented from <a href="qabstractitemmodel.html#mimeTypes">QAbstractItemModel</a>.</p>
133
<h3 class="fn"><a name="model"></a><a href="qabstractitemmodel.html">QAbstractItemModel</a> * QProxyModel::model () const</h3>
134
<p>Returns the model that contains the data that is available through the proxy model.</p>
135
<h3 class="fn"><a name="parent"></a><a href="qmodelindex.html">QModelIndex</a> QProxyModel::parent ( const <a href="qmodelindex.html">QModelIndex</a> & <i>child</i> ) const <tt> [virtual]</tt></h3>
136
<p>Returns the model index that corresponds to the parent of the given <i>child</i> index.</p>
137
<p>Reimplemented from <a href="qabstractitemmodel.html#parent">QAbstractItemModel</a>.</p>
138
<h3 class="fn"><a name="revert"></a>void QProxyModel::revert () <tt> [virtual]</tt></h3>
139
<p>Reimplemented from <a href="qabstractitemmodel.html#revert">QAbstractItemModel</a>.</p>
140
<h3 class="fn"><a name="rowCount"></a>int QProxyModel::rowCount ( const <a href="qmodelindex.html">QModelIndex</a> & <i>parent</i> ) const <tt> [virtual]</tt></h3>
141
<p>Returns the number of rows for the given <i>parent</i>.</p>
142
<p>Reimplemented from <a href="qabstractitemmodel.html#rowCount">QAbstractItemModel</a>.</p>
143
<p>See also <a href="qabstractitemmodel.html#rowCount">QAbstractItemModel::rowCount</a>().</p>
144
<h3 class="fn"><a name="setData"></a>bool QProxyModel::setData ( const <a href="qmodelindex.html">QModelIndex</a> & <i>index</i>, const <a href="qvariant.html">QVariant</a> & <i>value</i>, int <i>role</i> ) <tt> [virtual]</tt></h3>
145
<p>Sets the <i>role</i> data for the item at <i>index</i> to <i>value</i>. Returns true if successful; otherwise returns false.</p>
146
<p>The base class implementation returns false. This function and <a href="qproxymodel.html#data">data</a>() must be reimplemented for editable models.</p>
147
<p>Reimplemented from <a href="qabstractitemmodel.html#setData">QAbstractItemModel</a>.</p>
148
<p>See also <a href="qproxymodel.html#data">data</a>(), <a href="qabstractitemmodel.html#itemData">itemData</a>(), and <a href="qabstractitemmodel.html#setData">QAbstractItemModel::setData</a>().</p>
149
<h3 class="fn"><a name="setHeaderData"></a>bool QProxyModel::setHeaderData ( int <i>section</i>, <a href="qt.html#Orientation-enum">Qt::Orientation</a> <i>orientation</i>, const <a href="qvariant.html">QVariant</a> & <i>value</i>, int <i>role</i> ) <tt> [virtual]</tt></h3>
150
<p>Sets the <i>role</i> data in the <i>section</i> of the header with the specified <i>orientation</i> to the <i>value</i> given.</p>
151
<p>Reimplemented from <a href="qabstractitemmodel.html#setHeaderData">QAbstractItemModel</a>.</p>
152
<p>See also <a href="qabstractitemmodel.html#setHeaderData">QAbstractItemModel::setHeaderData</a>().</p>
153
<h3 class="fn"><a name="setModel"></a>void QProxyModel::setModel ( <a href="qabstractitemmodel.html">QAbstractItemModel</a> * <i>model</i> ) <tt> [virtual]</tt></h3>
154
<p>Sets the given <i>model</i> to be processed by the proxy model.</p>
155
<h3 class="fn"><a name="sort"></a>void QProxyModel::sort ( int <i>column</i>, <a href="qt.html#SortOrder-enum">Qt::SortOrder</a> <i>order</i> ) <tt> [virtual]</tt></h3>
156
<p>Sorts the child items in the specified <i>column</i> according to the sort order defined by <i>order</i>.</p>
157
<p>Reimplemented from <a href="qabstractitemmodel.html#sort">QAbstractItemModel</a>.</p>
158
<p>See also <a href="qabstractitemmodel.html#sort">QAbstractItemModel::sort</a>().</p>
159
<h3 class="fn"><a name="span"></a><a href="qsize.html">QSize</a> QProxyModel::span ( const <a href="qmodelindex.html">QModelIndex</a> & <i>index</i> ) const <tt> [virtual]</tt></h3>
160
<p>Returns the size of the item that corresponds to the specified <i>index</i>.</p>
161
<p>Reimplemented from <a href="qabstractitemmodel.html#span">QAbstractItemModel</a>.</p>
162
<h3 class="fn"><a name="submit"></a>bool QProxyModel::submit () <tt> [virtual]</tt></h3>
163
<p>Reimplemented from <a href="qabstractitemmodel.html#submit">QAbstractItemModel</a>.</p>
164
<h3 class="fn"><a name="supportedDropActions"></a><a href="qt.html#DropAction-enum">Qt::DropActions</a> QProxyModel::supportedDropActions () const <tt> [virtual]</tt></h3>
165
<p>Returns the drop actions that are supported by the model; this is a combination of the individual actions defined in <a href="qt.html#DropAction-enum">Qt::DropActions</a>.</p>
166
<p>The selection of drop actions provided by the model will influence the behavior of the component that started the drag and drop operation.</p>
167
<p>Reimplemented from <a href="qabstractitemmodel.html#supportedDropActions">QAbstractItemModel</a>.</p>
168
<p>See also <a href="dnd.html">Drag and Drop</a>.</p>
169
<p /><address><hr /><div align="center">
170
<table width="100%" cellspacing="0" border="0"><tr class="address">
171
<td width="30%">Copyright © 2005 <a href="trolltech.html">Trolltech</a></td>
172
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
173
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
174
</tr></table></div></address></body>