/usr/share/qt5/doc/qtquick/qml-qtquick-repeater.html is in qtdeclarative5-doc-html 5.5.1-2ubuntu6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | <?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.5</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="main">
<div class="main-rounded">
<div class="navigationbar">
<ul>
<li>Qt 5.5</li>
<li><a href="qtquick-index.html">Qt Quick</a></li>
<li><a href="qtquick-qmlmodule.html">QML Types</a></li>
<li>Repeater QML Type</li>
<li id="buildversion">Qt 5.5.1 Reference Documentation</li>
</ul>
</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.5</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>(index)</li>
</ul>
<!-- $$$Repeater-description -->
<a name="details"></a>
<h2 id="details">Detailed Description</h2>
</p>
<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="qtquick-positioning-layouts.html#row">Row</a> or <a href="qtquick-positioning-layouts.html#column">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="qtquick-positioning-layouts.html#row">Row</a>:</p>
<pre class="qml">import QtQuick 2.0
<span class="type"><a href="qml-qtquick-row.html">Row</a></span> {
<span class="type"><a href="qml-qtquick-repeater.html">Repeater</a></span> {
<span class="name">model</span>: <span class="number">3</span>
<span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
<span class="name">width</span>: <span class="number">100</span>; <span class="name">height</span>: <span class="number">40</span>
<span class="name">border</span>.width: <span class="number">1</span>
<span class="name">color</span>: <span class="string">"yellow"</span>
}
}
}</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"><span class="type"><a href="qml-qtquick-row.html">Row</a></span> {
<span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> { <span class="name">width</span>: <span class="number">10</span>; <span class="name">height</span>: <span class="number">20</span>; <span class="name">color</span>: <span class="string">"red"</span> }
<span class="type"><a href="qml-qtquick-repeater.html">Repeater</a></span> {
<span class="name">model</span>: <span class="number">10</span>
<span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> { <span class="name">width</span>: <span class="number">20</span>; <span class="name">height</span>: <span class="number">20</span>; <span class="name">radius</span>: <span class="number">10</span>; <span class="name">color</span>: <span class="string">"green"</span> }
}
<span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> { <span class="name">width</span>: <span class="number">10</span>; <span class="name">height</span>: <span class="number">20</span>; <span class="name">color</span>: <span class="string">"blue"</span> }
}</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 >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="cpp"><span class="comment">//bad code</span>
Item {
Can<span class="char">'t repeat QtObject as it doesn'</span>t derive from Item<span class="operator">.</span>
Repeater {
model: <span class="number">10</span>
<span class="type">QtObject</span> {}
}
}</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 repeater.</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"><span class="type"><a href="qml-qtquick-column.html">Column</a></span> {
<span class="type"><a href="qml-qtquick-repeater.html">Repeater</a></span> {
<span class="name">model</span>: <span class="number">10</span>
<span class="type"><a href="qml-qtquick-text.html">Text</a></span> { <span class="name">text</span>: <span class="string">"I'm item "</span> <span class="operator">+</span> <span class="name">index</span> }
}
}</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"><span class="type"><a href="qml-qtquick-column.html">Column</a></span> {
<span class="type"><a href="qml-qtquick-repeater.html">Repeater</a></span> {
<span class="name">model</span>: [<span class="string">"apples"</span>, <span class="string">"oranges"</span>, <span class="string">"pears"</span>]
<span class="type"><a href="qml-qtquick-text.html">Text</a></span> { <span class="name">text</span>: <span class="string">"Data: "</span> <span class="operator">+</span> <span class="name">modelData</span> }
}
}</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 <a href="qtquick-modelviewsdata-modelview.html#listmodel">ListModel</a>) 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. a <a href="qtquick-modelviewsdata-modelview.html#listmodel">ListModel</a> item, or a <a href="qtquick-modelviewsdata-cppmodels.html#qabstractitemmodel">QAbstractItemModel</a> 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>(<span class="type">index</span>)</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">©</acronym> 2015 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>
|