Sophie

Sophie

distrib > Mageia > 7 > i586 > media > core-updates > by-pkgid > 6e2327ca1c896c6d674ae53117299f21 > files > 1120

qtdeclarative5-doc-5.12.6-1.mga7.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" />
<!-- qquickrepeater.cpp -->
  <title>Repeater QML Type | Qt Quick 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="qtquick-index.html">Qt Quick</a></td><td ><a href="qtquick-qmlmodule.html">QML Types</a></td><td >Repeater QML Type</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtquick-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="#properties">Properties</a></li>
<li class="level1"><a href="#signals">Signals</a></li>
<li class="level1"><a href="#methods">Methods</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#considerations-when-using-repeater">Considerations when using Repeater</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Repeater QML Type</h1>
<span class="subtitle"></span>
<!-- $$$Repeater-brief -->
<p>Instantiates a number of Item-based components using a provided model. <a href="#details">More...</a></p>
<!-- @@@Repeater -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Import Statement:</td><td class="memItemRight bottomAlign"> import QtQuick 2.12</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <p><a href="qml-qtquick-item.html">Item</a></p>
</td></tr></table></div><ul>
<li><a href="qml-qtquick-repeater-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="properties"></a>
<h2 id="properties">Properties</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtquick-repeater.html#count-prop">count</a></b></b> : int</li>
<li class="fn"><b><b><a href="qml-qtquick-repeater.html#delegate-prop">delegate</a></b></b> : Component</li>
<li class="fn"><b><b><a href="qml-qtquick-repeater.html#model-prop">model</a></b></b> : any</li>
</ul>
<a name="signals"></a>
<h2 id="signals">Signals</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtquick-repeater.html#itemAdded-signal">itemAdded</a></b></b>(int <i>index</i>,  Item <i>item</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-repeater.html#itemRemoved-signal">itemRemoved</a></b></b>(int <i>index</i>,  Item <i>item</i>)</li>
</ul>
<a name="methods"></a>
<h2 id="methods">Methods</h2>
<ul>
<li class="fn">Item <b><b><a href="qml-qtquick-repeater.html#itemAt-method">itemAt</a></b></b>(<i>index</i>)</li>
</ul>
<!-- $$$Repeater-description -->
<a name="details"></a>
<h2 id="details">Detailed Description</h2>
<p>The Repeater type is used to create a large number of similar items. Like other view types, a Repeater has a <a href="qml-qtquick-repeater.html#model-prop">model</a> and a <a href="qml-qtquick-repeater.html#delegate-prop">delegate</a>: for each entry in the model, the delegate is instantiated in a context seeded with data from the model. A Repeater item is usually enclosed in a positioner type such as <a href="qml-qtquick-row.html">Row</a> or <a href="qml-qtquick-column.html">Column</a> to visually position the multiple delegate items created by the Repeater.</p>
<p>The following Repeater creates three instances of a <a href="qml-qtquick-rectangle.html">Rectangle</a> item within a <a href="qml-qtquick-row.html">Row</a>:</p>
<pre class="qml">

  import QtQuick 2.0

  Row {
      Repeater {
          model: 3
          Rectangle {
              width: 100; height: 40
              border.width: 1
              color: "yellow"
          }
      }
  }

</pre>
<p class="centerAlign"><img src="images/repeater-simple.png" alt="" /></p><p>A Repeater's <a href="qml-qtquick-repeater.html#model-prop">model</a> can be any of the supported <a href="qtquick-modelviewsdata-modelview.html#qml-data-models">data models</a>. Additionally, like delegates for other views, a Repeater delegate can access its index within the repeater, as well as the model data relevant to the delegate. See the <a href="qml-qtquick-repeater.html#delegate-prop">delegate</a> property documentation for details.</p>
<p>Items instantiated by the Repeater are inserted, in order, as children of the Repeater's parent. The insertion starts immediately after the repeater's position in its parent stacking list. This allows a Repeater to be used inside a layout. For example, the following Repeater's items are stacked between a red rectangle and a blue rectangle:</p>
<pre class="qml">

  Row {
      Rectangle { width: 10; height: 20; color: "red" }
      Repeater {
          model: 10
          Rectangle { width: 20; height: 20; radius: 10; color: "green" }
      }
      Rectangle { width: 10; height: 20; color: "blue" }
  }

</pre>
<p class="centerAlign"><img src="images/repeater.png" alt="" /></p><p><b>Note: </b>A Repeater item owns all items it instantiates. Removing or dynamically destroying an item created by a Repeater results in unpredictable behavior.</p><a name="considerations-when-using-repeater"></a>
<h3 id="considerations-when-using-repeater">Considerations when using Repeater</h3>
<p>The Repeater type creates all of its delegate items when the repeater is first created. This can be inefficient if there are a large number of delegate items and not all of the items are required to be visible at the same time. If this is the case, consider using other view types like <a href="qml-qtquick-listview.html">ListView</a> (which only creates delegate items when they are scrolled into view) or use the Dynamic Object Creation methods to create items as they are required.</p>
<p>Also, note that Repeater is <a href="qml-qtquick-item.html">Item</a>-based, and can only repeat <a href="qml-qtquick-item.html">Item</a>-derived objects. For example, it cannot be used to repeat QtObjects:</p>
<pre class="qml">



</pre>
<!-- @@@Repeater -->
<h2>Property Documentation</h2>
<!-- $$$count -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="count-prop">
<td class="tblQmlPropNode"><p>
<a name="count-prop"></a><span class="name">count</span> : <span class="type">int</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the number of items in the model.</p>
<p><b>Note: </b>The number of items in the model as reported by count may differ from the number of created delegates if the Repeater is in the process of instantiating delegates or is incorrectly set up.</p></div></div><!-- @@@count -->
<br/>
<!-- $$$delegate -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="delegate-prop">
<td class="tblQmlPropNode"><p>
<a name="delegate-prop"></a><span class="qmldefault">[default] </span><span class="name">delegate</span> : <span class="type">Component</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The delegate provides a template defining each item instantiated by the repeater.</p>
<p>Delegates are exposed to a read-only <code>index</code> property that indicates the index of the delegate within the repeater. For example, the following <a href="qml-qtquick-text.html">Text</a> delegate displays the index of each repeated item:</p>
<div class="table"><table class="generic">
 <tr valign="top" class="odd"><td ><pre class="qml">

  Column {
      Repeater {
          model: 10
          Text { text: "I'm item " + index }
      }
  }

</pre>
</td><td ><p class="centerAlign"><img src="images/repeater-index.png" alt="" /></p></td></tr>
</table></div>
<p>If the <a href="qml-qtquick-repeater.html#model-prop">model</a> is a <a href="qtquick-modelviewsdata-cppmodels.html#qstringlist-based-model">string list</a> or <a href="qtquick-modelviewsdata-cppmodels.html#qobjectlist-based-model">object list</a>, the delegate is also exposed to a read-only <code>modelData</code> property that holds the string or object data. For example:</p>
<div class="table"><table class="generic">
 <tr valign="top" class="odd"><td ><pre class="qml">

  Column {
      Repeater {
          model: ["apples", "oranges", "pears"]
          Text { text: "Data: " + modelData }
      }
  }

</pre>
</td><td ><p class="centerAlign"><img src="images/repeater-modeldata.png" alt="" /></p></td></tr>
</table></div>
<p>If the <a href="qml-qtquick-repeater.html#model-prop">model</a> is a model object (such as a ListModel) the delegate can access all model roles as named properties, in the same way that delegates do for view classes like <a href="qml-qtquick-listview.html">ListView</a>.</p>
<p><b>See also </b><a href="qtquick-modelviewsdata-modelview.html#qml-data-models">QML Data Models</a>.</p>
</div></div><!-- @@@delegate -->
<br/>
<!-- $$$model -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="model-prop">
<td class="tblQmlPropNode"><p>
<a name="model-prop"></a><span class="name">model</span> : <span class="type">any</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The model providing data for the repeater.</p>
<p>This property can be set to any of the supported <a href="qtquick-modelviewsdata-modelview.html#qml-data-models">data models</a>:</p>
<ul>
<li>A number that indicates the number of delegates to be created by the repeater</li>
<li>A model (e.g&#x2e; a ListModel item, or a QAbstractItemModel subclass)</li>
<li>A string list</li>
<li>An object list</li>
</ul>
<p>The type of model affects the properties that are exposed to the <a href="qml-qtquick-repeater.html#delegate-prop">delegate</a>.</p>
<p><b>See also </b><a href="qtquick-modelviewsdata-modelview.html#qml-data-models">Data Models</a>.</p>
</div></div><!-- @@@model -->
<br/>
<h2>Signal Documentation</h2>
<!-- $$$itemAdded -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="itemAdded-signal">
<td class="tblQmlFuncNode"><p>
<a name="itemAdded-signal"></a><span class="name">itemAdded</span>(<span class="type">int</span> <i>index</i>,  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> <i>item</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when an item is added to the repeater. The <i>index</i> parameter holds the index at which the item has been inserted within the repeater, and the <i>item</i> parameter holds the <a href="qml-qtquick-item.html">Item</a> that has been added.</p>
<p>The corresponding handler is <code>onItemAdded</code>.</p>
</div></div><!-- @@@itemAdded -->
<br/>
<!-- $$$itemRemoved -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="itemRemoved-signal">
<td class="tblQmlFuncNode"><p>
<a name="itemRemoved-signal"></a><span class="name">itemRemoved</span>(<span class="type">int</span> <i>index</i>,  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> <i>item</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when an item is removed from the repeater. The <i>index</i> parameter holds the index at which the item was removed from the repeater, and the <i>item</i> parameter holds the <a href="qml-qtquick-item.html">Item</a> that was removed.</p>
<p>Do not keep a reference to <i>item</i> if it was created by this repeater, as in these cases it will be deleted shortly after the signal is handled.</p>
<p>The corresponding handler is <code>onItemRemoved</code>.</p>
</div></div><!-- @@@itemRemoved -->
<br/>
<h2>Method Documentation</h2>
<!-- $$$itemAt -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="itemAt-method">
<td class="tblQmlFuncNode"><p>
<a name="itemAt-method"></a><span class="type"><a href="qml-qtquick-item.html">Item</a></span> <span class="name">itemAt</span>(<i>index</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>Returns the <a href="qml-qtquick-item.html">Item</a> that has been created at the given <i>index</i>, or <code>null</code> if no item exists at <i>index</i>.</p>
</div></div><!-- @@@itemAt -->
<br/>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</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>