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 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qdeclarativelistmodel.cpp -->
<title>Qt 4.8: QML ListModel Element</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="content">
<a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
</div>
<div class="breadcrumb toolblock">
<ul>
<li class="first"><a href="index.html">Home</a></li>
<!-- Breadcrumbs go here -->
<li><a href="qdeclarativeelements.html">QML Elements</a></li>
<li>QML ListModel Element</li>
</ul>
</div>
</div>
<div class="content mainContent">
<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="#methods">Methods</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#example-usage">Example Usage</a></li>
<li class="level2"><a href="#modifying-list-models">Modifying List Models</a></li>
<li class="level2"><a href="#using-threaded-list-models-with-workerscript">Using Threaded List Models with WorkerScript</a></li>
<li class="level2"><a href="#restrictions">Restrictions</a></li>
</ul>
</div>
<h1 class="title">QML ListModel Element</h1>
<span class="subtitle"></span>
<!-- $$$ListModel-brief -->
<p>The ListModel element defines a free-form list data source. <a href="#details">More...</a></p>
<!-- @@@ListModel -->
<p>This element was introduced in Qt 4.7.</p>
<ul>
<li><a href="qml-listmodel-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="properties"></a>
<h2>Properties</h2>
<ul>
<li class="fn"><b><b><a href="qml-listmodel.html#count-prop">count</a></b></b> : int</li>
</ul>
<a name="methods"></a>
<h2>Methods</h2>
<ul>
<li class="fn"><b><b><a href="qml-listmodel.html#append-method">append</a></b></b></li>
<li class="fn"><b><b><a href="qml-listmodel.html#clear-method">clear</a></b></b></li>
<li class="fn"><b><b><a href="qml-listmodel.html#get-method">get</a></b></b></li>
<li class="fn"><b><b><a href="qml-listmodel.html#insert-method">insert</a></b></b></li>
<li class="fn"><b><b><a href="qml-listmodel.html#move-method">move</a></b></b></li>
<li class="fn"><b><b><a href="qml-listmodel.html#remove-method">remove</a></b></b></li>
<li class="fn"><b><b><a href="qml-listmodel.html#set-method">set</a></b></b></li>
<li class="fn"><b><b><a href="qml-listmodel.html#setProperty-method">setProperty</a></b></b></li>
<li class="fn"><b><b><a href="qml-listmodel.html#sync-method">sync</a></b></b></li>
</ul>
<!-- $$$ListModel-description -->
<a name="details"></a>
<h2>Detailed Description</h2>
<p>The ListModel is a simple container of <a href="qml-listelement.html">ListElement</a> definitions, each containing data roles. The contents can be defined dynamically, or explicitly in QML.</p>
<p>The number of elements in the model can be obtained from its <a href="qml-listmodel.html#count-prop">count</a> property. A number of familiar methods are also provided to manipulate the contents of the model, including <a href="qml-listmodel.html#append-method">append()</a>, <a href="qml-listmodel.html#insert-method">insert()</a>, <a href="qml-listmodel.html#move-method">move()</a>, <a href="qml-listmodel.html#remove-method">remove()</a> and <a href="qml-listmodel.html#set-method">set()</a>. These methods accept dictionaries as their arguments; these are translated to <a href="qml-listelement.html">ListElement</a> objects by the model.</p>
<p>Elements can be manipulated via the model using the <a href="qml-listmodel.html#setProperty-method">setProperty()</a> method, which allows the roles of the specified element to be set and changed.</p>
<a name="example-usage"></a>
<h2>Example Usage</h2>
<p>The following example shows a ListModel containing three elements, with the roles "name" and "cost".</p>
<div class="float-right"><p><img src="images/listmodel.png" alt="" /></p>
</div><pre class="qml"> import QtQuick 1.0
<span class="type">ListModel</span> {
<span class="name">id</span>: <span class="name">fruitModel</span>
<span class="type"><a href="qml-listelement.html">ListElement</a></span> {
<span class="name">name</span>: <span class="string">"Apple"</span>
<span class="name">cost</span>: <span class="number">2.45</span>
}
<span class="type"><a href="qml-listelement.html">ListElement</a></span> {
<span class="name">name</span>: <span class="string">"Orange"</span>
<span class="name">cost</span>: <span class="number">3.25</span>
}
<span class="type"><a href="qml-listelement.html">ListElement</a></span> {
<span class="name">name</span>: <span class="string">"Banana"</span>
<span class="name">cost</span>: <span class="number">1.95</span>
}
}</pre>
<br style="clear: both" /><p>Roles (properties) in each element must begin with a lower-case letter and should be common to all elements in a model. The <a href="qml-listelement.html">ListElement</a> documentation provides more guidelines for how elements should be defined.</p>
<p>Since the example model contains an <tt>id</tt> property, it can be referenced by views, such as the <a href="qml-listview.html">ListView</a> in this example:</p>
<pre class="qml"> import QtQuick 1.0
<span class="type"><a href="qml-rectangle.html">Rectangle</a></span> {
<span class="name">width</span>: <span class="number">200</span>; <span class="name">height</span>: <span class="number">200</span>
<span class="type">ListModel</span> {
<span class="name">id</span>: <span class="name">fruitModel</span>
...
}
<span class="type"><a href="qml-component.html">Component</a></span> {
<span class="name">id</span>: <span class="name">fruitDelegate</span>
<span class="type"><a href="qml-row.html">Row</a></span> {
<span class="name">spacing</span>: <span class="number">10</span>
<span class="type"><a href="qml-text.html">Text</a></span> { <span class="name">text</span>: <span class="name">name</span> }
<span class="type"><a href="qml-text.html">Text</a></span> { <span class="name">text</span>: <span class="string">'$'</span> <span class="operator">+</span> <span class="name">cost</span> }
}
}
<span class="type"><a href="qml-listview.html">ListView</a></span> {
<span class="name">anchors</span>.fill: <span class="name">parent</span>
<span class="name">model</span>: <span class="name">fruitModel</span>
<span class="name">delegate</span>: <span class="name">fruitDelegate</span>
}
}</pre>
<p>It is possible for roles to contain list data. In the following example we create a list of fruit attributes:</p>
<pre class="qml"> <span class="type">ListModel</span> {
<span class="name">id</span>: <span class="name">fruitModel</span>
<span class="type"><a href="qml-listelement.html">ListElement</a></span> {
<span class="name">name</span>: <span class="string">"Apple"</span>
<span class="name">cost</span>: <span class="number">2.45</span>
<span class="name">attributes</span>: [
<span class="type"><a href="qml-listelement.html">ListElement</a></span> { <span class="name">description</span>: <span class="string">"Core"</span> },
<span class="type"><a href="qml-listelement.html">ListElement</a></span> { <span class="name">description</span>: <span class="string">"Deciduous"</span> }
]
}
<span class="type"><a href="qml-listelement.html">ListElement</a></span> {
<span class="name">name</span>: <span class="string">"Orange"</span>
<span class="name">cost</span>: <span class="number">3.25</span>
<span class="name">attributes</span>: [
<span class="type"><a href="qml-listelement.html">ListElement</a></span> { <span class="name">description</span>: <span class="string">"Citrus"</span> }
]
}
<span class="type"><a href="qml-listelement.html">ListElement</a></span> {
<span class="name">name</span>: <span class="string">"Banana"</span>
<span class="name">cost</span>: <span class="number">1.95</span>
<span class="name">attributes</span>: [
<span class="type"><a href="qml-listelement.html">ListElement</a></span> { <span class="name">description</span>: <span class="string">"Tropical"</span> },
<span class="type"><a href="qml-listelement.html">ListElement</a></span> { <span class="name">description</span>: <span class="string">"Seedless"</span> }
]
}
}</pre>
<p>The delegate displays all the fruit attributes:</p>
<div class="float-right"><p><img src="images/listmodel-nested.png" alt="" /></p>
</div><pre class="qml"> <span class="type"><a href="qml-component.html">Component</a></span> {
<span class="name">id</span>: <span class="name">fruitDelegate</span>
<span class="type"><a href="qml-item.html">Item</a></span> {
<span class="name">width</span>: <span class="number">200</span>; <span class="name">height</span>: <span class="number">50</span>
<span class="type"><a href="qml-text.html">Text</a></span> { <span class="name">id</span>: <span class="name">nameField</span>; <span class="name">text</span>: <span class="name">name</span> }
<span class="type"><a href="qml-text.html">Text</a></span> { <span class="name">text</span>: <span class="string">'$'</span> <span class="operator">+</span> <span class="name">cost</span>; <span class="name">anchors</span>.left: <span class="name">nameField</span>.<span class="name">right</span> }
<span class="type"><a href="qml-row.html">Row</a></span> {
<span class="name">anchors</span>.top: <span class="name">nameField</span>.<span class="name">bottom</span>
<span class="name">spacing</span>: <span class="number">5</span>
<span class="type"><a href="qml-text.html">Text</a></span> { <span class="name">text</span>: <span class="string">"Attributes:"</span> }
<span class="type"><a href="qml-repeater.html">Repeater</a></span> {
<span class="name">model</span>: <span class="name">attributes</span>
<span class="type"><a href="qml-text.html">Text</a></span> { <span class="name">text</span>: <span class="name">description</span> }
}
}
}
}</pre>
<br style="clear: both" /><a name="modifying-list-models"></a>
<h2>Modifying List Models</h2>
<p>The content of a ListModel may be created and modified using the <a href="qml-listmodel.html#clear-method">clear()</a>, <a href="qml-listmodel.html#append-method">append()</a>, <a href="qml-listmodel.html#set-method">set()</a>, <a href="qml-listmodel.html#insert-method">insert()</a> and <a href="qml-listmodel.html#setProperty-method">setProperty()</a> methods. For example:</p>
<pre class="qml"> <span class="type"><a href="qml-component.html">Component</a></span> {
<span class="name">id</span>: <span class="name">fruitDelegate</span>
<span class="type"><a href="qml-item.html">Item</a></span> {
<span class="name">width</span>: <span class="number">200</span>; <span class="name">height</span>: <span class="number">50</span>
<span class="type"><a href="qml-text.html">Text</a></span> { <span class="name">text</span>: <span class="name">name</span> }
<span class="type"><a href="qml-text.html">Text</a></span> { <span class="name">text</span>: <span class="string">'$'</span> <span class="operator">+</span> <span class="name">cost</span>; <span class="name">anchors</span>.right: <span class="name">parent</span>.<span class="name">right</span> }
<span class="comment">// Double the price when clicked.</span>
<span class="type"><a href="qml-mousearea.html">MouseArea</a></span> {
<span class="name">anchors</span>.fill: <span class="name">parent</span>
<span class="name">onClicked</span>: <span class="name">fruitModel</span>.<span class="name">setProperty</span>(<span class="name">index</span>, <span class="string">"cost"</span>, <span class="name">cost</span> <span class="operator">*</span> <span class="number">2</span>)
}
}
}</pre>
<p>Note that when creating content dynamically the set of available properties cannot be changed once set. Whatever properties are first added to the model are the only permitted properties in the model.</p>
<a name="using-threaded-list-models-with-workerscript"></a>
<h2>Using Threaded List Models with WorkerScript</h2>
<p>ListModel can be used together with <a href="qml-workerscript.html">WorkerScript</a> access a list model from multiple threads. This is useful if list modifications are synchronous and take some time: the list operations can be moved to a different thread to avoid blocking of the main GUI thread.</p>
<p>Here is an example that uses <a href="qml-workerscript.html">WorkerScript</a> to periodically append the current time to a list model:</p>
<pre class="qml"></pre>
<p>The included file, <tt>dataloader.js</tt>, looks like this:</p>
<pre class="js"></pre>
<p>The timer in the main example sends messages to the worker script by calling <a href="qml-workerscript.html#sendMessage-method">WorkerScript::sendMessage()</a>. When this message is received, <a href="qml-workerscript.html#onMessage-signal">WorkerScript.onMessage()</a> is invoked in <tt>dataloader.js</tt>, which appends the current time to the list model.</p>
<p>Note the call to <a href="qml-listmodel.html#sync-method">sync()</a> from the <a href="qml-workerscript.html#onMessage-signal">WorkerScript.onMessage()</a> handler. You must call <a href="qml-listmodel.html#sync-method">sync()</a> or else the changes made to the list from the external thread will not be reflected in the list model in the main thread.</p>
<a name="restrictions"></a>
<h2>Restrictions</h2>
<p>If a list model is to be accessed from a <a href="qml-workerscript.html">WorkerScript</a>, it cannot contain list-type data. So, the following model cannot be used from a <a href="qml-workerscript.html">WorkerScript</a> because of the list contained in the "attributes" property:</p>
<pre class="cpp"> ListModel {
id: fruitModel
ListElement {
name: <span class="string">"Apple"</span>
cost: <span class="number">2.45</span>
attributes: <span class="operator">[</span>
ListElement { description: <span class="string">"Core"</span> }<span class="operator">,</span>
ListElement { description: <span class="string">"Deciduous"</span> }
<span class="operator">]</span>
}
}</pre>
<p>In addition, the <a href="qml-workerscript.html">WorkerScript</a> cannot add list-type data to the model.</p>
<p><b>See also </b><a href="qdeclarativemodels.html#qmlmodels">Data Models</a>, <a href="declarative-threading-threadedlistmodel.html">Threaded ListModel example</a>, and <a href="qtdeclarative.html">QtDeclarative</a>.</p>
<!-- @@@ListModel -->
<h2>Property Documentation</h2>
<!-- $$$count -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="count-prop"></a><span class="qmlreadonly">read-only</span><span class="name">count</span> : <span class="type"><a href="qml-int.html">int</a></span></p></td></tr></table></div><div class="qmldoc"><p>The number of data entries in the model.</p>
</div></div><!-- @@@count -->
<br/>
<h2>Method Documentation</h2>
<!-- $$$append -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlFuncNode"><p><a name="append-method"></a>ListModel::<span class="name">append</span> ( <span class="type">jsobject</span> <i>dict</i> )</p></td></tr></table></div><div class="qmldoc"><p>Adds a new item to the end of the list model, with the values in <i>dict</i>.</p>
<pre class="cpp"> fruitModel<span class="operator">.</span>append({<span class="string">"cost"</span>: <span class="number">5.95</span><span class="operator">,</span> <span class="string">"name"</span>:<span class="string">"Pizza"</span>})</pre>
<p><b>See also </b><a href="qml-listmodel.html#set-method">set()</a> and <a href="qml-listmodel.html#remove-method">remove()</a>.</p>
</div></div><!-- @@@append -->
<br/>
<!-- $$$clear -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlFuncNode"><p><a name="clear-method"></a>ListModel::<span class="name">clear</span> ()</p></td></tr></table></div><div class="qmldoc"><p>Deletes all content from the model.</p>
<p><b>See also </b><a href="qml-listmodel.html#append-method">append()</a> and <a href="qml-listmodel.html#remove-method">remove()</a>.</p>
</div></div><!-- @@@clear -->
<br/>
<!-- $$$get -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlFuncNode"><p><a name="get-method"></a><span class="type">object</span> ListModel::<span class="name">get</span> ( <span class="type"><a href="qml-int.html">int</a></span> <i>index</i> )</p></td></tr></table></div><div class="qmldoc"><p>Returns the item at <i>index</i> in the list model. This allows the item data to be accessed or modified from JavaScript:</p>
<pre class="cpp"> Component<span class="operator">.</span>onCompleted: {
fruitModel<span class="operator">.</span>append({<span class="string">"cost"</span>: <span class="number">5.95</span><span class="operator">,</span> <span class="string">"name"</span>:<span class="string">"Jackfruit"</span>});
console<span class="operator">.</span>log(fruitModel<span class="operator">.</span>get(<span class="number">0</span>)<span class="operator">.</span>cost);
fruitModel<span class="operator">.</span>get(<span class="number">0</span>)<span class="operator">.</span>cost <span class="operator">=</span> <span class="number">10.95</span>;
}</pre>
<p>The <i>index</i> must be an element in the list.</p>
<p>Note that properties of the returned object that are themselves objects will also be models, and this get() method is used to access elements:</p>
<pre class="cpp"> fruitModel<span class="operator">.</span><a href="qml-listmodel.html#append-method">append</a>(<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span><span class="operator">,</span> <span class="string">"attributes"</span>:
<span class="operator">[</span>{<span class="string">"name"</span>:<span class="string">"spikes"</span><span class="operator">,</span><span class="string">"value"</span>:<span class="string">"7mm"</span>}<span class="operator">,</span>
{<span class="string">"name"</span>:<span class="string">"color"</span><span class="operator">,</span><span class="string">"value"</span>:<span class="string">"green"</span>}<span class="operator">]</span>);
fruitModel<span class="operator">.</span>get(<span class="number">0</span>)<span class="operator">.</span>attributes<span class="operator">.</span>get(<span class="number">1</span>)<span class="operator">.</span>value; <span class="comment">// == "green"</span></pre>
<p><b>Warning:</b> The returned object is not guaranteed to remain valid. It should not be used in <a href="propertybinding.html">property bindings</a>.</p>
<p><b>See also </b><a href="qml-listmodel.html#append-method">append()</a>.</p>
</div></div><!-- @@@get -->
<br/>
<!-- $$$insert -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlFuncNode"><p><a name="insert-method"></a>ListModel::<span class="name">insert</span> ( <span class="type"><a href="qml-int.html">int</a></span> <i>index</i>, <span class="type">jsobject</span> <i>dict</i> )</p></td></tr></table></div><div class="qmldoc"><p>Adds a new item to the list model at position <i>index</i>, with the values in <i>dict</i>.</p>
<pre class="cpp"> fruitModel<span class="operator">.</span>insert(<span class="number">2</span><span class="operator">,</span> {<span class="string">"cost"</span>: <span class="number">5.95</span><span class="operator">,</span> <span class="string">"name"</span>:<span class="string">"Pizza"</span>})</pre>
<p>The <i>index</i> must be to an existing item in the list, or one past the end of the list (equivalent to append).</p>
<p><b>See also </b><a href="qml-listmodel.html#set-method">set()</a> and <a href="qml-listmodel.html#append-method">append()</a>.</p>
</div></div><!-- @@@insert -->
<br/>
<!-- $$$move -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlFuncNode"><p><a name="move-method"></a>ListModel::<span class="name">move</span> ( <span class="type"><a href="qml-int.html">int</a></span> <i>from</i>, <span class="type"><a href="qml-int.html">int</a></span> <i>to</i>, <span class="type"><a href="qml-int.html">int</a></span> <i>n</i> )</p></td></tr></table></div><div class="qmldoc"><p>Moves <i>n</i> items <i>from</i> one position <i>to</i> another.</p>
<p>The from and to ranges must exist; for example, to move the first 3 items to the end of the list:</p>
<pre class="cpp"> fruitModel<span class="operator">.</span>move(<span class="number">0</span><span class="operator">,</span> fruitModel<span class="operator">.</span>count <span class="operator">-</span> <span class="number">3</span><span class="operator">,</span> <span class="number">3</span>)</pre>
<p><b>See also </b><a href="qml-listmodel.html#append-method">append()</a>.</p>
</div></div><!-- @@@move -->
<br/>
<!-- $$$remove -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlFuncNode"><p><a name="remove-method"></a>ListModel::<span class="name">remove</span> ( <span class="type"><a href="qml-int.html">int</a></span> <i>index</i> )</p></td></tr></table></div><div class="qmldoc"><p>Deletes the content at <i>index</i> from the model.</p>
<p><b>See also </b><a href="qml-listmodel.html#clear-method">clear()</a>.</p>
</div></div><!-- @@@remove -->
<br/>
<!-- $$$set -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlFuncNode"><p><a name="set-method"></a>ListModel::<span class="name">set</span> ( <span class="type"><a href="qml-int.html">int</a></span> <i>index</i>, <span class="type">jsobject</span> <i>dict</i> )</p></td></tr></table></div><div class="qmldoc"><p>Changes the item at <i>index</i> in the list model with the values in <i>dict</i>. Properties not appearing in <i>dict</i> are left unchanged.</p>
<pre class="cpp"> fruitModel<span class="operator">.</span>set(<span class="number">3</span><span class="operator">,</span> {<span class="string">"cost"</span>: <span class="number">5.95</span><span class="operator">,</span> <span class="string">"name"</span>:<span class="string">"Pizza"</span>})</pre>
<p>If <i>index</i> is equal to count() then a new item is appended to the list. Otherwise, <i>index</i> must be an element in the list.</p>
<p><b>See also </b><a href="qml-listmodel.html#append-method">append()</a>.</p>
</div></div><!-- @@@set -->
<br/>
<!-- $$$setProperty -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlFuncNode"><p><a name="setProperty-method"></a>ListModel::<span class="name">setProperty</span> ( <span class="type"><a href="qml-int.html">int</a></span> <i>index</i>, <span class="type"><a href="qml-string.html">string</a></span> <i>property</i>, <span class="type"><a href="qml-variant.html">variant</a></span> <i>value</i> )</p></td></tr></table></div><div class="qmldoc"><p>Changes the <i>property</i> of the item at <i>index</i> in the list model to <i>value</i>.</p>
<pre class="cpp"> fruitModel<span class="operator">.</span>setProperty(<span class="number">3</span><span class="operator">,</span> <span class="string">"cost"</span><span class="operator">,</span> <span class="number">5.95</span>)</pre>
<p>The <i>index</i> must be an element in the list.</p>
<p><b>See also </b><a href="qml-listmodel.html#append-method">append()</a>.</p>
</div></div><!-- @@@setProperty -->
<br/>
<!-- $$$sync -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlFuncNode"><p><a name="sync-method"></a>ListModel::<span class="name">sync</span> ()</p></td></tr></table></div><div class="qmldoc"><p>Writes any unsaved changes to the list model after it has been modified from a worker script.</p>
</div></div><!-- @@@sync -->
<br/>
<div class="ft">
<span></span>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2012 Nokia Corporation and/or its
subsidiaries. Documentation contributions included herein are the copyrights of
their respective owners.</p>
<br />
<p>
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.</p>
<p>
Documentation sources may be obtained from <a href="http://www.qt-project.org">
www.qt-project.org</a>.</p>
<br />
<p>
Nokia, Qt and their respective logos are trademarks of Nokia Corporation
in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. <a title="Privacy Policy"
href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>
|