Sophie

Sophie

distrib > Mageia > 6 > armv5tl > media > core-updates > by-pkgid > 768f7d9f703884aa2562bf0a651086df > files > 531

qtbase5-doc-5.9.4-1.1.mga6.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qabstractitemmodel.cpp -->
  <title>QModelIndex Class | Qt Core 5.9</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.9</td><td ><a href="qtcore-index.html">Qt Core</a></td><td ><a href="qtcore-module.html">C++ Classes</a></td><td >QModelIndex</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<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>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QModelIndex Class</h1>
<!-- $$$QModelIndex-brief -->
<p>The <a href="qmodelindex.html">QModelIndex</a> class is used to locate data in a data model. <a href="#details">More...</a></p>
<!-- @@@QModelIndex -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QModelIndex&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += core</td></tr></table></div><ul>
<li><a href="qmodelindex-members.html">List of all members, including inherited members</a></li>
<li><a href="qmodelindex-obsolete.html">Obsolete members</a></li>
</ul>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><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"> 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"> quintptr </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 &amp;<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&lt;</a></b>(const QModelIndex &amp;<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 &amp;<i>other</i>) const</td></tr>
</table></div>
<a name="related-non-members"></a>
<h2 id="related-non-members">Related Non-Members</h2>
<div class="table"><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></div>
<a name="details"></a>
<!-- $$$QModelIndex-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qmodelindex.html">QModelIndex</a> 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 <a href="qmodelindex.html">QModelIndex</a> 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 <a href="qmodelindex.html">QModelIndex</a> 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 child() 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="../qtwidgets/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" id="QModelIndex"><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 -->
<!-- $$$column[overload1]$$$column -->
<h3 class="fn" id="column"><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" id="data"><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" id="flags"><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" id="internalId"><a name="internalId"></a><span class="type"><a href="qtglobal.html#quintptr-typedef">quintptr</a></span> QModelIndex::<span class="name">internalId</span>() const</h3>
<p>Returns a <code>quintptr</code> 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" id="internalPointer"><a name="internalPointer"></a><span class="type">void</span> *QModelIndex::<span class="name">internalPointer</span>() const</h3>
<p>Returns a <code>void</code> <code>*</code> 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" id="isValid"><a name="isValid"></a><span class="type">bool</span> QModelIndex::<span class="name">isValid</span>() const</h3>
<p>Returns <code>true</code> if this model index is valid; otherwise returns <code>false</code>.</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" id="model"><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" id="parent"><a name="parent"></a><span class="type"><a href="qmodelindex.html#QModelIndex">QModelIndex</a></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#sibling">sibling</a>() and <a href="qmodelindex.html#model">model</a>().</p>
<!-- @@@parent -->
<!-- $$$row[overload1]$$$row -->
<h3 class="fn" id="row"><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" id="sibling"><a name="sibling"></a><span class="type"><a href="qmodelindex.html#QModelIndex">QModelIndex</a></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>().</p>
<!-- @@@sibling -->
<!-- $$$operator!=[overload1]$$$operator!=constQModelIndex& -->
<h3 class="fn" id="operator-not-eq"><a name="operator-not-eq"></a><span class="type">bool</span> QModelIndex::<span class="name">operator!=</span>(const <span class="type"><a href="qmodelindex.html#QModelIndex">QModelIndex</a></span> &amp;<i>other</i>) const</h3>
<p>Returns <code>true</code> if this model index does not refer to the same location as the <i>other</i> model index; otherwise returns <code>false</code>.</p>
<!-- @@@operator!= -->
<!-- $$$operator<[overload1]$$$operator<constQModelIndex& -->
<h3 class="fn" id="operator-lt"><a name="operator-lt"></a><span class="type">bool</span> QModelIndex::<span class="name">operator&lt;</span>(const <span class="type"><a href="qmodelindex.html#QModelIndex">QModelIndex</a></span> &amp;<i>other</i>) const</h3>
<p>Returns <code>true</code> if this model index is smaller than the <i>other</i> model index; otherwise returns <code>false</code>.</p>
<p>The less than calculation is not directly useful to developers - the way that indexes with different parents compare is not defined. This operator only exists so that the class can be used with <a href="qmap.html">QMap</a>.</p>
<p>This function was introduced in  Qt 4.1.</p>
<!-- @@@operator< -->
<!-- $$$operator==[overload1]$$$operator==constQModelIndex& -->
<h3 class="fn" id="operator-eq-eq"><a name="operator-eq-eq"></a><span class="type">bool</span> QModelIndex::<span class="name">operator==</span>(const <span class="type"><a href="qmodelindex.html#QModelIndex">QModelIndex</a></span> &amp;<i>other</i>) const</h3>
<p>Returns <code>true</code> if this model index refers to the same location as the <i>other</i> model index; otherwise returns <code>false</code>.</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" id="QModelIndexList-typedef"><a name="QModelIndexList-typedef"></a>typedef <span class="name">QModelIndexList</span></h3>
<p>Synonym for <a href="qlist.html">QList</a>&lt;<a href="qmodelindex.html">QModelIndex</a>&gt;.</p>
<!-- @@@QModelIndexList -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br>    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.<br>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>