1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qabstractitemmodel.cpp -->
<title>Qt 4.8: QModelIndex Class Reference</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="content">
<a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
</div>
<div class="breadcrumb toolblock">
<ul>
<li class="first"><a href="index.html">Home</a></li>
<!-- Breadcrumbs go here -->
<li><a href="modules.html">Modules</a></li>
<li><a href="qtcore.html">QtCore</a></li>
<li>QModelIndex</li>
</ul>
</div>
</div>
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#related-non-members">Related Non-Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<h1 class="title">QModelIndex Class Reference</h1>
<!-- $$$QModelIndex-brief -->
<p>The QModelIndex class is used to locate data in a data model. <a href="#details">More...</a></p>
<!-- @@@QModelIndex -->
<pre class="cpp"> <span class="preprocessor">#include <QModelIndex></span></pre><ul>
<li><a href="qmodelindex-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qmodelindex.html#QModelIndex">QModelIndex</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qmodelindex.html#QModelIndex-2">QModelIndex</a></b> ( const QModelIndex & <i>other</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qmodelindex.html#dtor.QModelIndex">~QModelIndex</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QModelIndex </td><td class="memItemRight bottomAlign"><b><a href="qmodelindex.html#child">child</a></b> ( int <i>row</i>, int <i>column</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qmodelindex.html#column">column</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVariant </td><td class="memItemRight bottomAlign"><b><a href="qmodelindex.html#data">data</a></b> ( int <i>role</i> = Qt::DisplayRole ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Qt::ItemFlags </td><td class="memItemRight bottomAlign"><b><a href="qmodelindex.html#flags">flags</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qint64 </td><td class="memItemRight bottomAlign"><b><a href="qmodelindex.html#internalId">internalId</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void * </td><td class="memItemRight bottomAlign"><b><a href="qmodelindex.html#internalPointer">internalPointer</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qmodelindex.html#isValid">isValid</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QAbstractItemModel * </td><td class="memItemRight bottomAlign"><b><a href="qmodelindex.html#model">model</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QModelIndex </td><td class="memItemRight bottomAlign"><b><a href="qmodelindex.html#parent">parent</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qmodelindex.html#row">row</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QModelIndex </td><td class="memItemRight bottomAlign"><b><a href="qmodelindex.html#sibling">sibling</a></b> ( int <i>row</i>, int <i>column</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qmodelindex.html#operator-not-eq">operator!=</a></b> ( const QModelIndex & <i>other</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qmodelindex.html#operator-lt">operator<</a></b> ( const QModelIndex & <i>other</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qmodelindex.html#operator-eq-eq">operator==</a></b> ( const QModelIndex & <i>other</i> ) const</td></tr>
</table>
<a name="related-non-members"></a>
<h2>Related Non-Members</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qmodelindex.html#QModelIndexList-typedef">QModelIndexList</a></b></td></tr>
</table>
<a name="details"></a>
<!-- $$$QModelIndex-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QModelIndex class is used to locate data in a data model.</p>
<p>This class is used as an index into item models derived from <a href="qabstractitemmodel.html">QAbstractItemModel</a>. The index is used by item views, delegates, and selection models to locate an item in the model.</p>
<p>New QModelIndex objects are created by the model using the <a href="qabstractitemmodel.html#createIndex">QAbstractItemModel::createIndex</a>() function. An <i>invalid</i> model index can be constructed with the QModelIndex constructor. Invalid indexes are often used as parent indexes when referring to top-level items in a model.</p>
<p>Model indexes refer to items in models, and contain all the information required to specify their locations in those models. Each index is located in a given row and column, and may have a parent index; use <a href="qmodelindex.html#row">row</a>(), <a href="qmodelindex.html#column">column</a>(), and <a href="qmodelindex.html#parent">parent</a>() to obtain this information. Each top-level item in a model is represented by a model index that does not have a parent index - in this case, <a href="qmodelindex.html#parent">parent</a>() will return an invalid model index, equivalent to an index constructed with the zero argument form of the <a href="qmodelindex.html#QModelIndex">QModelIndex</a>() constructor.</p>
<p>To obtain a model index that refers to an existing item in a model, call <a href="qabstractitemmodel.html#index">QAbstractItemModel::index</a>() with the required row and column values, and the model index of the parent. When referring to top-level items in a model, supply <a href="qmodelindex.html#QModelIndex">QModelIndex</a>() as the parent index.</p>
<p>The <a href="qmodelindex.html#model">model</a>() function returns the model that the index references as a <a href="qabstractitemmodel.html">QAbstractItemModel</a>. The <a href="qmodelindex.html#child">child</a>() function is used to examine items held under the index in the model. The <a href="qmodelindex.html#sibling">sibling</a>() function allows you to traverse items in the model on the same level as the index.</p>
<p><b>Note:</b> Model indexes should be used immediately and then discarded. You should not rely on indexes to remain valid after calling model functions that change the structure of the model or delete items. If you need to keep a model index over time use a <a href="qpersistentmodelindex.html">QPersistentModelIndex</a>.</p>
</div>
<p><b>See also </b><a href="model-view-programming.html">Model/View Programming</a>, <a href="qpersistentmodelindex.html">QPersistentModelIndex</a>, and <a href="qabstractitemmodel.html">QAbstractItemModel</a>.</p>
<!-- @@@QModelIndex -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QModelIndex[overload1]$$$QModelIndex -->
<h3 class="fn"><a name="QModelIndex"></a>QModelIndex::<span class="name">QModelIndex</span> ()</h3>
<p>Creates a new empty model index. This type of model index is used to indicate that the position in the model is invalid.</p>
<p><b>See also </b><a href="qmodelindex.html#isValid">isValid</a>() and <a href="qabstractitemmodel.html">QAbstractItemModel</a>.</p>
<!-- @@@QModelIndex -->
<!-- $$$QModelIndex$$$QModelIndexconstQModelIndex& -->
<h3 class="fn"><a name="QModelIndex-2"></a>QModelIndex::<span class="name">QModelIndex</span> ( const <span class="type">QModelIndex</span> & <i>other</i> )</h3>
<p>Creates a new model index that is a copy of the <i>other</i> model index.</p>
<!-- @@@QModelIndex -->
<!-- $$$~QModelIndex[overload1]$$$~QModelIndex -->
<h3 class="fn"><a name="dtor.QModelIndex"></a>QModelIndex::<span class="name">~QModelIndex</span> ()</h3>
<p>Destroys the model index.</p>
<!-- @@@~QModelIndex -->
<!-- $$$child[overload1]$$$childintint -->
<h3 class="fn"><a name="child"></a><span class="type">QModelIndex</span> QModelIndex::<span class="name">child</span> ( <span class="type">int</span> <i>row</i>, <span class="type">int</span> <i>column</i> ) const</h3>
<p>Returns the child of the model index that is stored in the given <i>row</i> and <i>column</i>.</p>
<p><b>Note:</b> This function does not work for an invalid model index which is often used as the root index.</p>
<p><b>See also </b><a href="qmodelindex.html#parent">parent</a>() and <a href="qmodelindex.html#sibling">sibling</a>().</p>
<!-- @@@child -->
<!-- $$$column[overload1]$$$column -->
<h3 class="fn"><a name="column"></a><span class="type">int</span> QModelIndex::<span class="name">column</span> () const</h3>
<p>Returns the column this model index refers to.</p>
<!-- @@@column -->
<!-- $$$data[overload1]$$$dataint -->
<h3 class="fn"><a name="data"></a><span class="type"><a href="qvariant.html">QVariant</a></span> QModelIndex::<span class="name">data</span> ( <span class="type">int</span> <i>role</i> = Qt::DisplayRole ) const</h3>
<p>Returns the data for the given <i>role</i> for the item referred to by the index.</p>
<!-- @@@data -->
<!-- $$$flags[overload1]$$$flags -->
<h3 class="fn"><a name="flags"></a><span class="type"><a href="qt.html#ItemFlag-enum">Qt::ItemFlags</a></span> QModelIndex::<span class="name">flags</span> () const</h3>
<p>Returns the flags for the item referred to by the index.</p>
<p>This function was introduced in Qt 4.2.</p>
<!-- @@@flags -->
<!-- $$$internalId[overload1]$$$internalId -->
<h3 class="fn"><a name="internalId"></a><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> QModelIndex::<span class="name">internalId</span> () const</h3>
<p>Returns a <tt>qint64</tt> used by the model to associate the index with the internal data structure.</p>
<p><b>See also </b><a href="qabstractitemmodel.html#createIndex">QAbstractItemModel::createIndex</a>().</p>
<!-- @@@internalId -->
<!-- $$$internalPointer[overload1]$$$internalPointer -->
<h3 class="fn"><a name="internalPointer"></a><span class="type">void</span> * QModelIndex::<span class="name">internalPointer</span> () const</h3>
<p>Returns a <tt>void</tt> <tt>*</tt> pointer used by the model to associate the index with the internal data structure.</p>
<p><b>See also </b><a href="qabstractitemmodel.html#createIndex">QAbstractItemModel::createIndex</a>().</p>
<!-- @@@internalPointer -->
<!-- $$$isValid[overload1]$$$isValid -->
<h3 class="fn"><a name="isValid"></a><span class="type">bool</span> QModelIndex::<span class="name">isValid</span> () const</h3>
<p>Returns true if this model index is valid; otherwise returns false.</p>
<p>A valid index belongs to a model, and has non-negative row and column numbers.</p>
<p><b>See also </b><a href="qmodelindex.html#model">model</a>(), <a href="qmodelindex.html#row">row</a>(), and <a href="qmodelindex.html#column">column</a>().</p>
<!-- @@@isValid -->
<!-- $$$model[overload1]$$$model -->
<h3 class="fn"><a name="model"></a>const <span class="type"><a href="qabstractitemmodel.html">QAbstractItemModel</a></span> * QModelIndex::<span class="name">model</span> () const</h3>
<p>Returns a pointer to the model containing the item that this index refers to.</p>
<p>A const pointer to the model is returned because calls to non-const functions of the model might invalidate the model index and possibly crash your application.</p>
<!-- @@@model -->
<!-- $$$parent[overload1]$$$parent -->
<h3 class="fn"><a name="parent"></a><span class="type">QModelIndex</span> QModelIndex::<span class="name">parent</span> () const</h3>
<p>Returns the parent of the model index, or <a href="qmodelindex.html#QModelIndex">QModelIndex</a>() if it has no parent.</p>
<p><b>See also </b><a href="qmodelindex.html#child">child</a>(), <a href="qmodelindex.html#sibling">sibling</a>(), and <a href="qmodelindex.html#model">model</a>().</p>
<!-- @@@parent -->
<!-- $$$row[overload1]$$$row -->
<h3 class="fn"><a name="row"></a><span class="type">int</span> QModelIndex::<span class="name">row</span> () const</h3>
<p>Returns the row this model index refers to.</p>
<!-- @@@row -->
<!-- $$$sibling[overload1]$$$siblingintint -->
<h3 class="fn"><a name="sibling"></a><span class="type">QModelIndex</span> QModelIndex::<span class="name">sibling</span> ( <span class="type">int</span> <i>row</i>, <span class="type">int</span> <i>column</i> ) const</h3>
<p>Returns the sibling at <i>row</i> and <i>column</i>. If there is no sibling at this position, an invalid <a href="qmodelindex.html">QModelIndex</a> is returned.</p>
<p><b>See also </b><a href="qmodelindex.html#parent">parent</a>() and <a href="qmodelindex.html#child">child</a>().</p>
<!-- @@@sibling -->
<!-- $$$operator!=[overload1]$$$operator!=constQModelIndex& -->
<h3 class="fn"><a name="operator-not-eq"></a><span class="type">bool</span> QModelIndex::<span class="name">operator!=</span> ( const <span class="type">QModelIndex</span> & <i>other</i> ) const</h3>
<p>Returns true if this model index does not refer to the same location as the <i>other</i> model index; otherwise returns false.</p>
<!-- @@@operator!= -->
<!-- $$$operator<[overload1]$$$operator<constQModelIndex& -->
<h3 class="fn"><a name="operator-lt"></a><span class="type">bool</span> QModelIndex::<span class="name">operator<</span> ( const <span class="type">QModelIndex</span> & <i>other</i> ) const</h3>
<p>Returns true if this model index is smaller than the <i>other</i> model index; otherwise returns false.</p>
<p>This function was introduced in Qt 4.1.</p>
<!-- @@@operator< -->
<!-- $$$operator==[overload1]$$$operator==constQModelIndex& -->
<h3 class="fn"><a name="operator-eq-eq"></a><span class="type">bool</span> QModelIndex::<span class="name">operator==</span> ( const <span class="type">QModelIndex</span> & <i>other</i> ) const</h3>
<p>Returns true if this model index refers to the same location as the <i>other</i> model index; otherwise returns false.</p>
<p>All values in the model index are used when comparing with another model index.</p>
<!-- @@@operator== -->
</div>
<div class="relnonmem">
<h2>Related Non-Members</h2>
<!-- $$$QModelIndexList -->
<h3 class="fn"><a name="QModelIndexList-typedef"></a>typedef <span class="name">QModelIndexList</span></h3>
<p>Synonym for <a href="qlist.html">QList</a><<a href="qmodelindex.html">QModelIndex</a>>.</p>
<!-- @@@QModelIndexList -->
</div>
<div class="ft">
<span></span>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2012 Nokia Corporation and/or its
subsidiaries. Documentation contributions included herein are the copyrights of
their respective owners.</p>
<br />
<p>
The documentation provided herein is licensed under the terms of the
<a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation
License version 1.3</a> as published by the Free Software Foundation.</p>
<p>
Documentation sources may be obtained from <a href="http://www.qt-project.org">
www.qt-project.org</a>.</p>
<br />
<p>
Nokia, Qt and their respective logos are trademarks of Nokia Corporation
in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. <a title="Privacy Policy"
href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>
|