<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qvariant.cpp --> <title>QSequentialIterable Class | Qt Core 5.12.6</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.12</td><td ><a href="qtcore-index.html">Qt Core</a></td><td ><a href="qtcore-module.html">C++ Classes</a></td><td >QSequentialIterable</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right"><a href="qtcore-index.html">Qt 5.12.6 Reference Documentation</a></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-types">Public Types</a></li> <li class="level1"><a href="#public-functions">Public Functions</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">QSequentialIterable Class</h1> <!-- $$$QSequentialIterable-brief --> <p>The <a href="qsequentialiterable.html">QSequentialIterable</a> class is an iterable interface for a container in a <a href="qvariant.html">QVariant</a>. <a href="#details">More...</a></p> <!-- @@@QSequentialIterable --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QSequentialIterable></span> </td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += core</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign"> Qt 5.2</td></tr></table></div><ul> <li><a href="qsequentialiterable-members.html">List of all members, including inherited members</a></li> </ul> <a name="public-types"></a> <h2 id="public-types">Public Types</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> class </td><td class="memItemRight bottomAlign"><b><a href="qsequentialiterable-const-iterator.html">const_iterator</a></b></td></tr> </table></div> <a name="public-functions"></a> <h2 id="public-functions">Public Functions</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> QVariant </td><td class="memItemRight bottomAlign"><b><a href="qsequentialiterable.html#at">at</a></b>(int <i>idx</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QSequentialIterable::const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qsequentialiterable.html#begin">begin</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsequentialiterable.html#canReverseIterate">canReverseIterate</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QSequentialIterable::const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qsequentialiterable.html#end">end</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qsequentialiterable.html#size">size</a></b>() const</td></tr> </table></div> <a name="details"></a> <!-- $$$QSequentialIterable-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qsequentialiterable.html">QSequentialIterable</a> class is an iterable interface for a container in a <a href="qvariant.html">QVariant</a>.</p> <p>This class allows several methods of accessing the elements of a container held within a <a href="qvariant.html">QVariant</a>. An instance of <a href="qsequentialiterable.html">QSequentialIterable</a> can be extracted from a <a href="qvariant.html">QVariant</a> if it can be converted to a <a href="qvariant.html#QVariantList-typedef">QVariantList</a>.</p> <pre class="cpp"> <span class="type"><a href="qlist.html">QList</a></span><span class="operator"><</span><span class="type">int</span><span class="operator">></span> intList <span class="operator">=</span> {<span class="number">7</span><span class="operator">,</span> <span class="number">11</span><span class="operator">,</span> <span class="number">42</span>}; <span class="type"><a href="qvariant.html">QVariant</a></span> variant <span class="operator">=</span> <span class="type"><a href="qvariant.html">QVariant</a></span><span class="operator">::</span>fromValue(intList); <span class="keyword">if</span> (variant<span class="operator">.</span>canConvert<span class="operator"><</span><span class="type"><a href="qvariant.html#QVariantList-typedef">QVariantList</a></span><span class="operator">></span>()) { <span class="type">QSequentialIterable</span> iterable <span class="operator">=</span> variant<span class="operator">.</span>value<span class="operator"><</span><span class="type">QSequentialIterable</span><span class="operator">></span>(); <span class="comment">// Can use foreach:</span> foreach (<span class="keyword">const</span> <span class="type"><a href="qvariant.html">QVariant</a></span> <span class="operator">&</span>v<span class="operator">,</span> iterable) { <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> v; } <span class="comment">// Can use C++11 range-for:</span> <span class="keyword">for</span> (<span class="keyword">const</span> <span class="type"><a href="qvariant.html">QVariant</a></span> <span class="operator">&</span>v : iterable) { <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> v; } <span class="comment">// Can use iterators:</span> <span class="type">QSequentialIterable</span><span class="operator">::</span>const_iterator it <span class="operator">=</span> iterable<span class="operator">.</span>begin(); <span class="keyword">const</span> <span class="type">QSequentialIterable</span><span class="operator">::</span>const_iterator end <span class="operator">=</span> iterable<span class="operator">.</span>end(); <span class="keyword">for</span> ( ; it <span class="operator">!</span><span class="operator">=</span> end; <span class="operator">+</span><span class="operator">+</span>it) { <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> <span class="operator">*</span>it; } } </pre> <p>The container itself is not copied before iterating over it.</p> </div> <p><b>See also </b><a href="qvariant.html">QVariant</a>.</p> <!-- @@@QSequentialIterable --> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$at[overload1]$$$atint --> <h3 class="fn" id="at"><a name="at"></a><span class="type"><a href="qvariant.html">QVariant</a></span> QSequentialIterable::<span class="name">at</span>(<span class="type">int</span> <i>idx</i>) const</h3> <p>Returns the element at position <i>idx</i> in the container.</p> <!-- @@@at --> <!-- $$$begin[overload1]$$$begin --> <h3 class="fn" id="begin"><a name="begin"></a><span class="type"><a href="qsequentialiterable-const-iterator.html">QSequentialIterable::const_iterator</a></span> QSequentialIterable::<span class="name">begin</span>() const</h3> <p>Returns a <a href="qsequentialiterable-const-iterator.html">QSequentialIterable::const_iterator</a> for the beginning of the container. This can be used in stl-style iteration.</p> <p><b>See also </b><a href="qsequentialiterable.html#end">end</a>().</p> <!-- @@@begin --> <!-- $$$canReverseIterate[overload1]$$$canReverseIterate --> <h3 class="fn" id="canReverseIterate"><a name="canReverseIterate"></a><span class="type">bool</span> QSequentialIterable::<span class="name">canReverseIterate</span>() const</h3> <p>Returns whether it is possible to iterate over the container in reverse. This corresponds to the std::bidirectional_iterator_tag iterator trait of the <a href="qsequentialiterable-const-iterator.html">const_iterator</a> of the container.</p> <!-- @@@canReverseIterate --> <!-- $$$end[overload1]$$$end --> <h3 class="fn" id="end"><a name="end"></a><span class="type"><a href="qsequentialiterable-const-iterator.html">QSequentialIterable::const_iterator</a></span> QSequentialIterable::<span class="name">end</span>() const</h3> <p>Returns a <a href="qsequentialiterable-const-iterator.html">QSequentialIterable::const_iterator</a> for the end of the container. This can be used in stl-style iteration.</p> <p><b>See also </b><a href="qsequentialiterable.html#begin">begin</a>().</p> <!-- @@@end --> <!-- $$$size[overload1]$$$size --> <h3 class="fn" id="size"><a name="size"></a><span class="type">int</span> QSequentialIterable::<span class="name">size</span>() const</h3> <p>Returns the number of elements in the container.</p> <!-- @@@size --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2019 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>