Sophie

Sophie

distrib > Fedora > 18 > x86_64 > by-pkgid > ff187cb994c94c614ecc64c5a8528b1b > files > 6012

qt-doc-4.8.5-10.fc18.noarch.rpm

<?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/style.css" />
  <script src="scripts/jquery.js" type="text/javascript"></script>
  <script src="scripts/functions.js" type="text/javascript"></script>
  <link rel="stylesheet" type="text/css" href="style/superfish.css" />
  <link rel="stylesheet" type="text/css" href="style/narrow.css" />
  <!--[if IE]>
<meta name="MSSmartTagsPreventParsing" content="true">
<meta http-equiv="imagetoolbar" content="no">
<![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie6.css">
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie7.css">
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="style/style_ie8.css">
<![endif]-->

<script src="scripts/superfish.js" type="text/javascript"></script>
<script src="scripts/narrow.js" type="text/javascript"></script>

</head>
<body class="" onload="CheckEmptyAndLoadList();">
 <div class="header" id="qtdocheader">
    <div class="content"> 
    <div id="nav-logo">
      <a href="index.html">Home</a></div>
    <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
    <div id="narrowsearch"></div>
    <div id="nav-topright">
      <ul>
        <li class="nav-topright-home"><a href="http://qt.digia.com/">Qt HOME</a></li>
        <li class="nav-topright-dev"><a href="http://qt-project.org/">DEV</a></li>
        <li class="nav-topright-doc nav-topright-doc-active"><a href="http://qt-project.org/doc/">
          DOC</a></li>
        <li class="nav-topright-blog"><a href="http://blog.qt.digia.com/">BLOG</a></li>
      </ul>
    </div>
    <div id="shortCut">
      <ul>
        <li class="shortCut-topleft-inactive"><span><a href="index.html">Qt 4.8</a></span></li>
        <li class="shortCut-topleft-active"><a href="http://qt-project.org/doc/">ALL VERSIONS        </a></li>
      </ul>
     </div>
 <ul class="sf-menu" id="narrowmenu"> 
             <li><a href="#">API Lookup</a> 
                 <ul> 
                     <li><a href="classes.html">Class index</a></li> 
           <li><a href="functions.html">Function index</a></li> 
           <li><a href="modules.html">Modules</a></li> 
           <li><a href="namespaces.html">Namespaces</a></li> 
           <li><a href="qtglobal.html">Global Declarations</a></li> 
           <li><a href="qdeclarativeelements.html">QML elements</a></li> 
             </ul> 
             </li> 
             <li><a href="#">Qt Topics</a> 
                 <ul> 
                        <li><a href="qt-basic-concepts.html">Programming with Qt</a></li>  
                        <li><a href="qtquick.html">Device UIs &amp; Qt Quick</a></li>  
                        <li><a href="qt-gui-concepts.html">UI Design with Qt</a></li>  
                        <li><a href="supported-platforms.html">Supported Platforms</a></li>  
                        <li><a href="technology-apis.html">Qt and Key Technologies</a></li>  
                        <li><a href="best-practices.html">How-To's and Best Practices</a></li>  
              </ul> 
                 </li> 
                 <li><a href="#">Examples</a> 
                     <ul> 
                       <li><a href="all-examples.html">Examples</a></li> 
                       <li><a href="tutorials.html">Tutorials</a></li> 
                       <li><a href="demos.html">Demos</a></li> 
                       <li><a href="qdeclarativeexamples.html">QML Examples</a></li> 
                </ul> 
                     </li> 
                 </ul> 
    </div>
  </div>
  <div class="wrapper">
    <div class="hd">
      <span></span>
    </div>
    <div class="bd group">
      <div class="sidebar">
        <div class="searchlabel">
          Search index:</div>
        <div class="search" id="sidebarsearch">
          <form id="qtdocsearch" action="" onsubmit="return false;">
            <fieldset>
              <input type="text" name="searchstring" id="pageType" value="" />
 <div id="resultdialog"> 
 <a href="#" id="resultclose">Close</a> 
 <p id="resultlinks" class="all"><a href="#" id="showallresults">All</a> | <a href="#" id="showapiresults">API</a> | <a href="#" id="showarticleresults">Articles</a> | <a href="#" id="showexampleresults">Examples</a></p> 
 <p id="searchcount" class="all"><span id="resultcount"></span><span id="apicount"></span><span id="articlecount"></span><span id="examplecount"></span>&nbsp;results:</p> 
 <ul id="resultlist" class="all"> 
 </ul> 
 </div> 
            </fieldset>
          </form>
        </div>
        <div class="box first bottombar" id="lookup">
          <h2 title="API Lookup"><span></span>
            API Lookup</h2>
          <div  id="list001" class="list">
          <ul id="ul001" >
              <li class="defaultLink"><a href="classes.html">Class index</a></li>
              <li class="defaultLink"><a href="functions.html">Function index</a></li>
              <li class="defaultLink"><a href="modules.html">Modules</a></li>
              <li class="defaultLink"><a href="namespaces.html">Namespaces</a></li>
              <li class="defaultLink"><a href="qtglobal.html">Global Declarations</a></li>
              <li class="defaultLink"><a href="qdeclarativeelements.html">QML elements</a></li>
            </ul> 
          </div>
        </div>
        <div class="box bottombar" id="topics">
          <h2 title="Qt Topics"><span></span>
            Qt Topics</h2>
          <div id="list002" class="list">
            <ul id="ul002" >
               <li class="defaultLink"><a href="qt-basic-concepts.html">Programming with Qt</a></li> 
               <li class="defaultLink"><a href="qtquick.html">Device UIs &amp; Qt Quick</a></li> 
               <li class="defaultLink"><a href="qt-gui-concepts.html">UI Design with Qt</a></li> 
               <li class="defaultLink"><a href="supported-platforms.html">Supported Platforms</a></li>  
               <li class="defaultLink"><a href="technology-apis.html">Qt and Key Technologies</a></li> 
               <li class="defaultLink"><a href="best-practices.html">How-To's and Best Practices</a></li> 
            </ul>  
          </div>
        </div>
        <div class="box" id="examples">
          <h2 title="Examples"><span></span>
            Examples</h2>
          <div id="list003" class="list">
        <ul id="ul003">
              <li class="defaultLink"><a href="all-examples.html">Examples</a></li>
              <li class="defaultLink"><a href="tutorials.html">Tutorials</a></li>
              <li class="defaultLink"><a href="demos.html">Demos</a></li>
              <li class="defaultLink"><a href="qdeclarativeexamples.html">QML Examples</a></li>
            </ul> 
          </div>
        </div>
      </div>
      <div class="wrap">
        <div class="toolbar">
          <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 class="toolbuttons toolblock">
            <ul>
              <li id="smallA" class="t_button">A</li>
              <li id="medA" class="t_button active">A</li>
              <li id="bigA" class="t_button">A</li>
              <li id="print" class="t_button"><a href="javascript:this.print();">
                <span>Print</span></a></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 &lt;QModelIndex&gt;</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 &amp; <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 &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>
<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> &amp; <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> &amp; <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&lt;</span> ( const <span class="type">QModelIndex</span> &amp; <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> &amp; <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>&lt;<a href="qmodelindex.html">QModelIndex</a>&gt;.</p>
<!-- @@@QModelIndexList -->
</div>
      </div>
    </div>
    </div> 
    <div class="ft">
      <span></span>
    </div>
  </div> 
  <div class="footer">
    <p>
      <acronym title="Copyright">&copy;</acronym> 2013 Digia Plc 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>
      Digia, Qt and their respective logos are trademarks of Digia Plc 
      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>

  <script src="scripts/functions.js" type="text/javascript"></script>
</body>
</html>