<?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>QPersistentModelIndex Class | Qt Core 5.11</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 ><a href="../qtdoc/index.html">Qt 5.11</a></td><td ><a href="qtcore-index.html">Qt Core</a></td><td ><a href="qtcore-module.html">C++ Classes</a></td><td >QPersistentModelIndex</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right">Qt 5.11.2 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">QPersistentModelIndex Class</h1> <!-- $$$QPersistentModelIndex-brief --> <p>The <a href="qpersistentmodelindex.html">QPersistentModelIndex</a> class is used to locate data in a data model. <a href="#details">More...</a></p> <!-- @@@QPersistentModelIndex --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QPersistentModelIndex></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="qpersistentmodelindex-members.html">List of all members, including inherited members</a></li> <li><a href="qpersistentmodelindex-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="qpersistentmodelindex.html#QPersistentModelIndex">QPersistentModelIndex</a></b>(const QModelIndex &<i>index</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qpersistentmodelindex.html#QPersistentModelIndex-2">QPersistentModelIndex</a></b>(const QPersistentModelIndex &<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qpersistentmodelindex.html#QPersistentModelIndex-3">QPersistentModelIndex</a></b>(QPersistentModelIndex &&<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qpersistentmodelindex.html#column">column</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QVariant </td><td class="memItemRight bottomAlign"><b><a href="qpersistentmodelindex.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="qpersistentmodelindex.html#flags">flags</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qpersistentmodelindex.html#isValid">isValid</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const QAbstractItemModel *</td><td class="memItemRight bottomAlign"><b><a href="qpersistentmodelindex.html#model">model</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QModelIndex </td><td class="memItemRight bottomAlign"><b><a href="qpersistentmodelindex.html#parent">parent</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qpersistentmodelindex.html#row">row</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QModelIndex </td><td class="memItemRight bottomAlign"><b><a href="qpersistentmodelindex.html#sibling">sibling</a></b>(int <i>row</i>, int <i>column</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpersistentmodelindex.html#swap">swap</a></b>(QPersistentModelIndex &<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const QModelIndex &</td><td class="memItemRight bottomAlign"><b><a href="qpersistentmodelindex.html#operator-const-QModelIndex--and">operator const QModelIndex &</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qpersistentmodelindex.html#operator-not-eq">operator!=</a></b>(const QPersistentModelIndex &<i>other</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qpersistentmodelindex.html#operator-not-eq-1">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="qpersistentmodelindex.html#operator-lt">operator<</a></b>(const QPersistentModelIndex &<i>other</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QPersistentModelIndex &</td><td class="memItemRight bottomAlign"><b><a href="qpersistentmodelindex.html#operator-eq">operator=</a></b>(const QPersistentModelIndex &<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QPersistentModelIndex &</td><td class="memItemRight bottomAlign"><b><a href="qpersistentmodelindex.html#operator-eq-1">operator=</a></b>(QPersistentModelIndex &&<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QPersistentModelIndex &</td><td class="memItemRight bottomAlign"><b><a href="qpersistentmodelindex.html#operator-eq-2">operator=</a></b>(const QModelIndex &<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qpersistentmodelindex.html#operator-eq-eq">operator==</a></b>(const QPersistentModelIndex &<i>other</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qpersistentmodelindex.html#operator-eq-eq-1">operator==</a></b>(const QModelIndex &<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"> uint </td><td class="memItemRight bottomAlign"><b><a href="qpersistentmodelindex.html#qHash">qHash</a></b>(const QPersistentModelIndex &<i>index</i>, uint <i>seed</i> = ...)</td></tr> </table></div> <a name="details"></a> <!-- $$$QPersistentModelIndex-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qpersistentmodelindex.html">QPersistentModelIndex</a> class is used to locate data in a data model.</p> <p>A <a href="qpersistentmodelindex.html">QPersistentModelIndex</a> is a model index that can be stored by an application, and later used to access information in a model. Unlike the <a href="qmodelindex.html">QModelIndex</a> class, it is safe to store a <a href="qpersistentmodelindex.html">QPersistentModelIndex</a> since the model will ensure that references to items will continue to be valid as long as they can be accessed by the model.</p> <p>It is good practice to check that persistent model indexes are valid before using them.</p> </div> <p><b>See also </b><a href="../qtwidgets/model-view-programming.html">Model/View Programming</a>, <a href="qmodelindex.html">QModelIndex</a>, and <a href="qabstractitemmodel.html">QAbstractItemModel</a>.</p> <!-- @@@QPersistentModelIndex --> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QPersistentModelIndex[overload1]$$$QPersistentModelIndexconstQModelIndex& --> <h3 class="fn" id="QPersistentModelIndex"><a name="QPersistentModelIndex"></a>QPersistentModelIndex::<span class="name">QPersistentModelIndex</span>(const <span class="type"><a href="qmodelindex.html">QModelIndex</a></span> &<i>index</i>)</h3> <p>Creates a new <a href="qpersistentmodelindex.html">QPersistentModelIndex</a> that is a copy of the model <i>index</i>.</p> <!-- @@@QPersistentModelIndex --> <!-- $$$QPersistentModelIndex$$$QPersistentModelIndexconstQPersistentModelIndex& --> <h3 class="fn" id="QPersistentModelIndex-2"><a name="QPersistentModelIndex-2"></a>QPersistentModelIndex::<span class="name">QPersistentModelIndex</span>(const <span class="type"><a href="qpersistentmodelindex.html#QPersistentModelIndex">QPersistentModelIndex</a></span> &<i>other</i>)</h3> <p>Creates a new <a href="qpersistentmodelindex.html">QPersistentModelIndex</a> that is a copy of the <i>other</i> persistent model index.</p> <!-- @@@QPersistentModelIndex --> <!-- $$$QPersistentModelIndex$$$QPersistentModelIndexQPersistentModelIndex&& --> <h3 class="fn" id="QPersistentModelIndex-3"><a name="QPersistentModelIndex-3"></a>QPersistentModelIndex::<span class="name">QPersistentModelIndex</span>(<span class="type"><a href="qpersistentmodelindex.html#QPersistentModelIndex">QPersistentModelIndex</a></span> &&<i>other</i>)</h3> <p>Move-constructs a <a href="qpersistentmodelindex.html">QPersistentModelIndex</a> instance, making it point at the same object that <i>other</i> was pointing to.</p> <p>This function was introduced in Qt 5.2.</p> <!-- @@@QPersistentModelIndex --> <!-- $$$column[overload1]$$$column --> <h3 class="fn" id="column"><a name="column"></a><span class="type">int</span> QPersistentModelIndex::<span class="name">column</span>() const</h3> <p>Returns the column this persistent 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> QPersistentModelIndex::<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> <p><b>See also </b><a href="qt.html#ItemDataRole-enum">Qt::ItemDataRole</a> and <a href="qabstractitemmodel.html#setData">QAbstractItemModel::setData</a>().</p> <!-- @@@data --> <!-- $$$flags[overload1]$$$flags --> <h3 class="fn" id="flags"><a name="flags"></a><span class="type">Qt::ItemFlags</span> QPersistentModelIndex::<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 --> <!-- $$$isValid[overload1]$$$isValid --> <h3 class="fn" id="isValid"><a name="isValid"></a><span class="type">bool</span> QPersistentModelIndex::<span class="name">isValid</span>() const</h3> <p>Returns <code>true</code> if this persistent 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="qpersistentmodelindex.html#model">model</a>(), <a href="qpersistentmodelindex.html#row">row</a>(), and <a href="qpersistentmodelindex.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> *QPersistentModelIndex::<span class="name">model</span>() const</h3> <p>Returns the model that the index belongs to.</p> <!-- @@@model --> <!-- $$$parent[overload1]$$$parent --> <h3 class="fn" id="parent"><a name="parent"></a><span class="type"><a href="qmodelindex.html">QModelIndex</a></span> QPersistentModelIndex::<span class="name">parent</span>() const</h3> <p>Returns the parent <a href="qmodelindex.html">QModelIndex</a> for this persistent index, or an invalid <a href="qmodelindex.html">QModelIndex</a> if it has no parent.</p> <p><b>See also </b><a href="qpersistentmodelindex.html#sibling">sibling</a>() and <a href="qpersistentmodelindex.html#model">model</a>().</p> <!-- @@@parent --> <!-- $$$row[overload1]$$$row --> <h3 class="fn" id="row"><a name="row"></a><span class="type">int</span> QPersistentModelIndex::<span class="name">row</span>() const</h3> <p>Returns the row this persistent 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</a></span> QPersistentModelIndex::<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> or an invalid <a href="qmodelindex.html">QModelIndex</a> if there is no sibling at this position.</p> <p><b>See also </b><a href="qpersistentmodelindex.html#parent">parent</a>().</p> <!-- @@@sibling --> <!-- $$$swap[overload1]$$$swapQPersistentModelIndex& --> <h3 class="fn" id="swap"><a name="swap"></a><span class="type">void</span> QPersistentModelIndex::<span class="name">swap</span>(<span class="type"><a href="qpersistentmodelindex.html#QPersistentModelIndex">QPersistentModelIndex</a></span> &<i>other</i>)</h3> <p>Swaps this persistent modelindex with <i>other</i>. This function is very fast and never fails.</p> <p>This function was introduced in Qt 5.0.</p> <!-- @@@swap --> <!-- $$$operator const QModelIndex &[overload1]$$$operator const QModelIndex & --> <h3 class="fn" id="operator-const-QModelIndex--and"><a name="operator-const-QModelIndex--and"></a>const <span class="type"><a href="qmodelindex.html">QModelIndex</a></span> &QPersistentModelIndex::<span class="name">operator const QModelIndex &</span>() const</h3> <p>Cast operator that returns a const <a href="qmodelindex.html">QModelIndex</a>&.</p> <!-- @@@operator const QModelIndex & --> <!-- $$$operator!=[overload1]$$$operator!=constQPersistentModelIndex& --> <h3 class="fn" id="operator-not-eq"><a name="operator-not-eq"></a><span class="type">bool</span> QPersistentModelIndex::<span class="name">operator!=</span>(const <span class="type"><a href="qpersistentmodelindex.html#QPersistentModelIndex">QPersistentModelIndex</a></span> &<i>other</i>) const</h3> <p>Returns <code>true</code> if this persistent model index is not equal to the <i>other</i> persistent model index; otherwise returns <code>false</code>.</p> <p>This function was introduced in Qt 4.2.</p> <!-- @@@operator!= --> <!-- $$$operator!=$$$operator!=constQModelIndex& --> <h3 class="fn" id="operator-not-eq-1"><a name="operator-not-eq-1"></a><span class="type">bool</span> QPersistentModelIndex::<span class="name">operator!=</span>(const <span class="type"><a href="qmodelindex.html">QModelIndex</a></span> &<i>other</i>) const</h3> <p>Returns <code>true</code> if this persistent 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<constQPersistentModelIndex& --> <h3 class="fn" id="operator-lt"><a name="operator-lt"></a><span class="type">bool</span> QPersistentModelIndex::<span class="name">operator<</span>(const <span class="type"><a href="qpersistentmodelindex.html#QPersistentModelIndex">QPersistentModelIndex</a></span> &<i>other</i>) const</h3> <p>Returns <code>true</code> if this persistent model index is smaller than the <i>other</i> persistent model index; otherwise returns <code>false</code>.</p> <p>The internal data pointer, row, column, and model values in the persistent model index are used when comparing with another persistent model index.</p> <p>This function was introduced in Qt 4.1.</p> <!-- @@@operator< --> <!-- $$$operator=[overload1]$$$operator=constQPersistentModelIndex& --> <h3 class="fn" id="operator-eq"><a name="operator-eq"></a><span class="type"><a href="qpersistentmodelindex.html#QPersistentModelIndex">QPersistentModelIndex</a></span> &QPersistentModelIndex::<span class="name">operator=</span>(const <span class="type"><a href="qpersistentmodelindex.html#QPersistentModelIndex">QPersistentModelIndex</a></span> &<i>other</i>)</h3> <p>Sets the persistent model index to refer to the same item in a model as the <i>other</i> persistent model index.</p> <!-- @@@operator= --> <!-- $$$operator=$$$operator=QPersistentModelIndex&& --> <h3 class="fn" id="operator-eq-1"><a name="operator-eq-1"></a><span class="type"><a href="qpersistentmodelindex.html#QPersistentModelIndex">QPersistentModelIndex</a></span> &QPersistentModelIndex::<span class="name">operator=</span>(<span class="type"><a href="qpersistentmodelindex.html#QPersistentModelIndex">QPersistentModelIndex</a></span> &&<i>other</i>)</h3> <p>Move-assigns <i>other</i> to this <a href="qpersistentmodelindex.html">QPersistentModelIndex</a> instance.</p> <p>This function was introduced in Qt 5.2.</p> <!-- @@@operator= --> <!-- $$$operator=$$$operator=constQModelIndex& --> <h3 class="fn" id="operator-eq-2"><a name="operator-eq-2"></a><span class="type"><a href="qpersistentmodelindex.html#QPersistentModelIndex">QPersistentModelIndex</a></span> &QPersistentModelIndex::<span class="name">operator=</span>(const <span class="type"><a href="qmodelindex.html">QModelIndex</a></span> &<i>other</i>)</h3> <p>Sets the persistent model index to refer to the same item in a model as the <i>other</i> model index.</p> <!-- @@@operator= --> <!-- $$$operator==[overload1]$$$operator==constQPersistentModelIndex& --> <h3 class="fn" id="operator-eq-eq"><a name="operator-eq-eq"></a><span class="type">bool</span> QPersistentModelIndex::<span class="name">operator==</span>(const <span class="type"><a href="qpersistentmodelindex.html#QPersistentModelIndex">QPersistentModelIndex</a></span> &<i>other</i>) const</h3> <p>Returns <code>true</code> if this persistent model index is equal to the <i>other</i> persistent model index; otherwise returns <code>false</code>.</p> <p>The internal data pointer, row, column, and model values in the persistent model index are used when comparing with another persistent model index.</p> <!-- @@@operator== --> <!-- $$$operator==$$$operator==constQModelIndex& --> <h3 class="fn" id="operator-eq-eq-1"><a name="operator-eq-eq-1"></a><span class="type">bool</span> QPersistentModelIndex::<span class="name">operator==</span>(const <span class="type"><a href="qmodelindex.html">QModelIndex</a></span> &<i>other</i>) const</h3> <p>Returns <code>true</code> if this persistent model index refers to the same location as the <i>other</i> model index; otherwise returns <code>false</code>.</p> <p>The internal data pointer, row, column, and model values in the persistent model index are used when comparing with another model index.</p> <!-- @@@operator== --> </div> <div class="relnonmem"> <h2>Related Non-Members</h2> <!-- $$$qHash[overload1]$$$qHashconstQPersistentModelIndex&uint --> <h3 class="fn" id="qHash"><a name="qHash"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(const <span class="type"><a href="qpersistentmodelindex.html#QPersistentModelIndex">QPersistentModelIndex</a></span> &<i>index</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = ...)</h3> <p>Returns a hash of the <a href="qpersistentmodelindex.html">QPersistentModelIndex</a> <i>index</i>, using <i>seed</i> to seed the calculation.</p> <p>This function was introduced in Qt 5.0.</p> <!-- @@@qHash --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2018 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>