Sophie

Sophie

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

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" />
<!-- qvariant.cpp -->
  <title>QAssociativeIterable 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 >QAssociativeIterable</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-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">QAssociativeIterable Class</h1>
<!-- $$$QAssociativeIterable-brief -->
<p>The <a href="qassociativeiterable.html">QAssociativeIterable</a> class is an iterable interface for an associative container in a <a href="qvariant.html">QVariant</a>. <a href="#details">More...</a></p>
<!-- @@@QAssociativeIterable -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QAssociativeIterable&gt;</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="qassociativeiterable-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="qassociativeiterable-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"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qassociativeiterable.html#begin">begin</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qassociativeiterable.html#end">end</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qassociativeiterable.html#find">find</a></b>(const QVariant &amp;<i>key</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qassociativeiterable.html#size">size</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVariant </td><td class="memItemRight bottomAlign"><b><a href="qassociativeiterable.html#value">value</a></b>(const QVariant &amp;<i>key</i>) const</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QAssociativeIterable-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qassociativeiterable.html">QAssociativeIterable</a> class is an iterable interface for an associative container in a <a href="qvariant.html">QVariant</a>.</p>
<p>This class allows several methods of accessing the elements of an associative container held within a <a href="qvariant.html">QVariant</a>. An instance of <a href="qassociativeiterable.html">QAssociativeIterable</a> can be extracted from a <a href="qvariant.html">QVariant</a> if it can be converted to a <a href="qvariant.html#QVariantHash-typedef">QVariantHash</a> or <a href="qvariant.html#QVariantMap-typedef">QVariantMap</a>.</p>
<pre class="cpp">

  <span class="type"><a href="qhash.html">QHash</a></span><span class="operator">&lt;</span><span class="type">int</span><span class="operator">,</span> <span class="type"><a href="qstring.html">QString</a></span><span class="operator">&gt;</span> mapping;
  mapping<span class="operator">.</span>insert(<span class="number">7</span><span class="operator">,</span> <span class="string">&quot;Seven&quot;</span>);
  mapping<span class="operator">.</span>insert(<span class="number">11</span><span class="operator">,</span> <span class="string">&quot;Eleven&quot;</span>);
  mapping<span class="operator">.</span>insert(<span class="number">42</span><span class="operator">,</span> <span class="string">&quot;Forty-two&quot;</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(mapping);
  <span class="keyword">if</span> (variant<span class="operator">.</span>canConvert<span class="operator">&lt;</span><span class="type"><a href="qvariant.html#QVariantHash-typedef">QVariantHash</a></span><span class="operator">&gt;</span>()) {
      <span class="type">QAssociativeIterable</span> iterable <span class="operator">=</span> variant<span class="operator">.</span>value<span class="operator">&lt;</span><span class="type">QAssociativeIterable</span><span class="operator">&gt;</span>();
      <span class="comment">// Can use foreach over the values:</span>
      foreach (<span class="keyword">const</span> <span class="type"><a href="qvariant.html">QVariant</a></span> <span class="operator">&amp;</span>v<span class="operator">,</span> iterable) {
          <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> v;
      }
      <span class="comment">// Can use C++11 range-for over the values:</span>
      <span class="keyword">for</span> (<span class="keyword">const</span> <span class="type"><a href="qvariant.html">QVariant</a></span> <span class="operator">&amp;</span>v : iterable) {
          <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> v;
      }
      <span class="comment">// Can use iterators:</span>
      <span class="type">QAssociativeIterable</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">QAssociativeIterable</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">&lt;</span><span class="operator">&lt;</span> <span class="operator">*</span>it; <span class="comment">// The current value</span>
          <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> it<span class="operator">.</span>key();
          <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> it<span class="operator">.</span>value();
      }
  }

</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>
<!-- @@@QAssociativeIterable -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$begin[overload1]$$$begin -->
<h3 class="fn" id="begin"><a name="begin"></a><span class="type"><a href="qassociativeiterable-const-iterator.html">const_iterator</a></span> QAssociativeIterable::<span class="name">begin</span>() const</h3>
<p>Returns a <a href="qassociativeiterable-const-iterator.html">QAssociativeIterable::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="qassociativeiterable.html#end">end</a>().</p>
<!-- @@@begin -->
<!-- $$$end[overload1]$$$end -->
<h3 class="fn" id="end"><a name="end"></a><span class="type"><a href="qassociativeiterable-const-iterator.html">const_iterator</a></span> QAssociativeIterable::<span class="name">end</span>() const</h3>
<p>Returns a <a href="qassociativeiterable-const-iterator.html">QAssociativeIterable::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="qassociativeiterable.html#begin">begin</a>().</p>
<!-- @@@end -->
<!-- $$$find[overload1]$$$findconstQVariant& -->
<h3 class="fn" id="find"><a name="find"></a><span class="type"><a href="qassociativeiterable-const-iterator.html">const_iterator</a></span> QAssociativeIterable::<span class="name">find</span>(const <span class="type"><a href="qvariant.html">QVariant</a></span> &amp;<i>key</i>) const</h3>
<p>Returns a <a href="qassociativeiterable-const-iterator.html">QAssociativeIterable::const_iterator</a> for the given key <i>key</i> in the container, if the types are convertible.</p>
<p>If the key is not found, returns <a href="qassociativeiterable.html#end">end</a>().</p>
<p>This can be used in stl-style iteration.</p>
<p>This function was introduced in  Qt 5.5.</p>
<p><b>See also </b><a href="qassociativeiterable.html#begin">begin</a>(), <a href="qassociativeiterable.html#end">end</a>(), and <a href="qassociativeiterable.html#value">value</a>().</p>
<!-- @@@find -->
<!-- $$$size[overload1]$$$size -->
<h3 class="fn" id="size"><a name="size"></a><span class="type">int</span> QAssociativeIterable::<span class="name">size</span>() const</h3>
<p>Returns the number of elements in the container.</p>
<!-- @@@size -->
<!-- $$$value[overload1]$$$valueconstQVariant& -->
<h3 class="fn" id="value"><a name="value"></a><span class="type"><a href="qvariant.html">QVariant</a></span> QAssociativeIterable::<span class="name">value</span>(const <span class="type"><a href="qvariant.html">QVariant</a></span> &amp;<i>key</i>) const</h3>
<p>Returns the value for the given <i>key</i> in the container, if the types are convertible.</p>
<p><b>See also </b><a href="qassociativeiterable.html#find">find</a>().</p>
<!-- @@@value -->
</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>