/usr/share/qt5/doc/qtquick/qtquick-views-example.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 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 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- views.qdoc -->
<title>Qt Quick Examples - Views | 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>Qt Quick Examples - Views</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="#running-the-example">Running the Example</a></li>
<li class="level1"><a href="#gridview-and-pathview">GridView and PathView</a></li>
<li class="level1"><a href="#dynamic-list">Dynamic List</a></li>
<li class="level2"><a href="#expanding-delegates">Expanding Delegates</a></li>
<li class="level1"><a href="#highlight">Highlight</a></li>
<li class="level1"><a href="#highlight-ranges">Highlight Ranges</a></li>
<li class="level1"><a href="#sections">Sections</a></li>
<li class="level1"><a href="#packages">Packages</a></li>
<li class="level1"><a href="#objectmodel">ObjectModel</a></li>
<li class="level1"><a href="#display-margins">Display Margins</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Qt Quick Examples - Views</h1>
<span class="subtitle"></span>
<!-- $$$views-description -->
<div class="descr"> <a name="details"></a>
<p class="centerAlign"><img src="images/qml-modelviews-example.png" alt="" /></p><p><i>Views</i> is a collection of small QML examples relating to model and view functionality. They demonstrate how to show data from a model using the Qt Quick view types. For more information, visit the <a href="qtquick-modelviewsdata-modelview.html">Models and Views in Qt Quick</a> page.</p>
<a name="running-the-example"></a>
<h2 id="running-the-example">Running the Example</h2>
<p>To run the example from Qt Creator, open the <b>Welcome</b> mode and select the example from <b>Examples</b>. For more information, visit Building and Running an Example.</p>
<a name="gridview-and-pathview"></a>
<h2 id="gridview-and-pathview">GridView and PathView</h2>
<p><i>GridView</i> and <i>PathView</i> demonstrate usage of these types to display views.</p>
<pre class="qml"> <span class="type"><a href="qml-qtquick-gridview.html">GridView</a></span> {
<span class="name">anchors</span>.fill: <span class="name">parent</span>
<span class="name">cellWidth</span>: <span class="number">100</span>; <span class="name">cellHeight</span>: <span class="number">100</span>
<span class="name">focus</span>: <span class="number">true</span>
<span class="name">model</span>: <span class="name">appModel</span>
<span class="name">highlight</span>: <span class="name">Rectangle</span> { <span class="name">width</span>: <span class="number">80</span>; <span class="name">height</span>: <span class="number">80</span>; <span class="name">color</span>: <span class="string">"lightsteelblue"</span> }
<span class="name">delegate</span>: <span class="name">Item</span> {
<span class="name">width</span>: <span class="number">100</span>; <span class="name">height</span>: <span class="number">100</span>
<span class="type"><a href="qml-qtquick-image.html">Image</a></span> {
<span class="name">id</span>: <span class="name">myIcon</span>
<span class="name">y</span>: <span class="number">20</span>; <span class="name">anchors</span>.horizontalCenter: <span class="name">parent</span>.<span class="name">horizontalCenter</span>
<span class="name">source</span>: <span class="name">icon</span>
}
<span class="type"><a href="qml-qtquick-text.html">Text</a></span> {
<span class="type">anchors</span> { <span class="name">top</span>: <span class="name">myIcon</span>.<span class="name">bottom</span>; <span class="name">horizontalCenter</span>: <span class="name">parent</span>.<span class="name">horizontalCenter</span> }
<span class="name">text</span>: <span class="name">name</span>
}
<span class="type"><a href="qml-qtquick-mousearea.html">MouseArea</a></span> {
<span class="name">anchors</span>.fill: <span class="name">parent</span>
<span class="name">onClicked</span>: <span class="name">parent</span>.<span class="name">GridView</span>.<span class="name">view</span>.<span class="name">currentIndex</span> <span class="operator">=</span> <span class="name">index</span>
}
}
}</pre>
<a name="dynamic-list"></a>
<h2 id="dynamic-list">Dynamic List</h2>
<p><i>Dynamic List</i> demonstrates animation of runtime additions and removals to a <a href="qml-qtquick-listview.html">ListView</a>.</p>
<p>The <a href="qml-qtquick-listview.html">ListView</a>.onAdd signal handler runs an animation when new items are added to the view, and the <a href="qml-qtquick-listview.html">ListView</a>.onRemove another when they are removed.</p>
<pre class="qml"> <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
<span class="name">ListView</span>.onAdd: <span class="name">SequentialAnimation</span> {
<span class="type"><a href="qml-qtquick-propertyaction.html">PropertyAction</a></span> { <span class="name">target</span>: <span class="name">delegateItem</span>; <span class="name">property</span>: <span class="string">"height"</span>; <span class="name">value</span>: <span class="number">0</span> }
<span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></span> { <span class="name">target</span>: <span class="name">delegateItem</span>; <span class="name">property</span>: <span class="string">"height"</span>; <span class="name">to</span>: <span class="number">80</span>; <span class="name">duration</span>: <span class="number">250</span>; <span class="name">easing</span>.type: <span class="name">Easing</span>.<span class="name">InOutQuad</span> }
}
<span class="name">ListView</span>.onRemove: <span class="name">SequentialAnimation</span> {
<span class="type"><a href="qml-qtquick-propertyaction.html">PropertyAction</a></span> { <span class="name">target</span>: <span class="name">delegateItem</span>; <span class="name">property</span>: <span class="string">"ListView.delayRemove"</span>; <span class="name">value</span>: <span class="number">true</span> }
<span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></span> { <span class="name">target</span>: <span class="name">delegateItem</span>; <span class="name">property</span>: <span class="string">"height"</span>; <span class="name">to</span>: <span class="number">0</span>; <span class="name">duration</span>: <span class="number">250</span>; <span class="name">easing</span>.type: <span class="name">Easing</span>.<span class="name">InOutQuad</span> }
<span class="comment">// Make sure delayRemove is set back to false so that the item can be destroyed</span>
<span class="type"><a href="qml-qtquick-propertyaction.html">PropertyAction</a></span> { <span class="name">target</span>: <span class="name">delegateItem</span>; <span class="name">property</span>: <span class="string">"ListView.delayRemove"</span>; <span class="name">value</span>: <span class="number">false</span> }
}
}</pre>
<a name="expanding-delegates"></a>
<h3 >Expanding Delegates</h3>
<p><i>Expanding Delegates</i> demonstrates delegates that expand when activated.</p>
<p>It has a complex delegate the size and appearance of which can change, displacing other items in the view.</p>
<pre class="qml"> <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
<span class="name">id</span>: <span class="name">recipe</span>
<span class="comment">// Create a property to contain the visibility of the details.</span>
<span class="comment">// We can bind multiple element's opacity to this one property,</span>
<span class="comment">// rather than having a "PropertyChanges" line for each element we</span>
<span class="comment">// want to fade.</span>
property <span class="type">real</span> <span class="name">detailsOpacity</span> : <span class="number">0</span>
<span class="type"><a href="qml-qtquick-mousearea.html">MouseArea</a></span> {
<span class="name">anchors</span>.fill: <span class="name">parent</span>
<span class="name">onClicked</span>: <span class="name">recipe</span>.<span class="name">state</span> <span class="operator">=</span> <span class="string">'Details'</span>;
}
<span class="comment">// Lay out the page: picture, title and ingredients at the top, and method at the</span>
<span class="comment">// bottom. Note that elements that should not be visible in the list</span>
<span class="comment">// mode have their opacity set to recipe.detailsOpacity.</span>
<span class="type"><a href="qml-qtquick-row.html">Row</a></span> {
<span class="name">id</span>: <span class="name">topLayout</span>
<span class="name">x</span>: <span class="number">10</span>; <span class="name">y</span>: <span class="number">10</span>; <span class="name">height</span>: <span class="name">recipeImage</span>.<span class="name">height</span>; <span class="name">width</span>: <span class="name">parent</span>.<span class="name">width</span>
<span class="name">spacing</span>: <span class="number">10</span>
<span class="type"><a href="qml-qtquick-image.html">Image</a></span> {
<span class="name">id</span>: <span class="name">recipeImage</span>
<span class="name">width</span>: <span class="number">50</span>; <span class="name">height</span>: <span class="number">50</span>
<span class="name">source</span>: <span class="name">picture</span>
}
<span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
<span class="name">id</span>: <span class="name">details</span>
<span class="name">x</span>: <span class="number">10</span>; <span class="name">width</span>: <span class="name">parent</span>.<span class="name">width</span> <span class="operator">-</span> <span class="number">20</span>
<span class="type">anchors</span> { <span class="name">top</span>: <span class="name">topLayout</span>.<span class="name">bottom</span>; <span class="name">topMargin</span>: <span class="number">10</span>; <span class="name">bottom</span>: <span class="name">parent</span>.<span class="name">bottom</span>; <span class="name">bottomMargin</span>: <span class="number">10</span> }
<span class="name">opacity</span>: <span class="name">recipe</span>.<span class="name">detailsOpacity</span>
}
<span class="comment">// A button to close the detailed view, i.e. set the state back to default ('').</span>
<span class="type">TextButton</span> {
<span class="name">y</span>: <span class="number">10</span>
<span class="type">anchors</span> { <span class="name">right</span>: <span class="name">background</span>.<span class="name">right</span>; <span class="name">rightMargin</span>: <span class="number">10</span> }
<span class="name">opacity</span>: <span class="name">recipe</span>.<span class="name">detailsOpacity</span>
<span class="name">text</span>: <span class="string">"Close"</span>
<span class="name">onClicked</span>: <span class="name">recipe</span>.<span class="name">state</span> <span class="operator">=</span> <span class="string">''</span>;
}
<span class="name">states</span>: <span class="name">State</span> {
<span class="name">name</span>: <span class="string">"Details"</span>
<span class="type"><a href="qml-qtquick-propertychanges.html">PropertyChanges</a></span> { <span class="name">target</span>: <span class="name">background</span>; <span class="name">color</span>: <span class="string">"white"</span> }
<span class="type"><a href="qml-qtquick-propertychanges.html">PropertyChanges</a></span> { <span class="name">target</span>: <span class="name">recipeImage</span>; <span class="name">width</span>: <span class="number">130</span>; <span class="name">height</span>: <span class="number">130</span> } <span class="comment">// Make picture bigger</span>
<span class="type"><a href="qml-qtquick-propertychanges.html">PropertyChanges</a></span> { <span class="name">target</span>: <span class="name">recipe</span>; <span class="name">detailsOpacity</span>: <span class="number">1</span>; <span class="name">x</span>: <span class="number">0</span> } <span class="comment">// Make details visible</span>
<span class="type"><a href="qml-qtquick-propertychanges.html">PropertyChanges</a></span> { <span class="name">target</span>: <span class="name">recipe</span>; <span class="name">height</span>: <span class="name">listView</span>.<span class="name">height</span> } <span class="comment">// Fill the entire list area with the detailed view</span>
<span class="comment">// Move the list so that this item is at the top.</span>
<span class="type"><a href="qml-qtquick-propertychanges.html">PropertyChanges</a></span> { <span class="name">target</span>: <span class="name">recipe</span>.<span class="name">ListView</span>.<span class="name">view</span>; <span class="name">explicit</span>: <span class="number">true</span>; <span class="name">contentY</span>: <span class="name">recipe</span>.<span class="name">y</span> }
<span class="comment">// Disallow flicking while we're in detailed view</span>
<span class="type"><a href="qml-qtquick-propertychanges.html">PropertyChanges</a></span> { <span class="name">target</span>: <span class="name">recipe</span>.<span class="name">ListView</span>.<span class="name">view</span>; <span class="name">interactive</span>: <span class="number">false</span> }
}
<span class="name">transitions</span>: <span class="name">Transition</span> {
<span class="comment">// Make the state changes smooth</span>
<span class="type"><a href="qml-qtquick-parallelanimation.html">ParallelAnimation</a></span> {
<span class="type"><a href="qml-qtquick-coloranimation.html">ColorAnimation</a></span> { <span class="name">property</span>: <span class="string">"color"</span>; <span class="name">duration</span>: <span class="number">500</span> }
<span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></span> { <span class="name">duration</span>: <span class="number">300</span>; <span class="name">properties</span>: <span class="string">"detailsOpacity,x,contentY,height,width"</span> }
}
}
}</pre>
<a name="highlight"></a>
<h2 id="highlight">Highlight</h2>
<p><i>Highlight</i> demonstrates adding a custom highlight to a <a href="qml-qtquick-listview.html">ListView</a>.</p>
<pre class="qml"> <span class="comment">// Define a highlight with customized movement between items.</span>
<span class="type">Component</span> {
<span class="name">id</span>: <span class="name">highlightBar</span>
<span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
<span class="name">width</span>: <span class="number">200</span>; <span class="name">height</span>: <span class="number">50</span>
<span class="name">color</span>: <span class="string">"#FFFF88"</span>
<span class="name">y</span>: <span class="name">listView</span>.<span class="name">currentItem</span>.<span class="name">y</span>;
Behavior on <span class="name">y</span> { <span class="type"><a href="qml-qtquick-springanimation.html">SpringAnimation</a></span> { <span class="name">spring</span>: <span class="number">2</span>; <span class="name">damping</span>: <span class="number">0.1</span> } }
}
}
<span class="type"><a href="qml-qtquick-listview.html">ListView</a></span> {
<span class="name">id</span>: <span class="name">listView</span>
<span class="name">width</span>: <span class="number">200</span>; <span class="name">height</span>: <span class="name">parent</span>.<span class="name">height</span>
<span class="name">x</span>: <span class="number">30</span>
<span class="name">model</span>: <span class="name">PetsModel</span> {}
<span class="name">delegate</span>: <span class="name">petDelegate</span>
<span class="name">focus</span>: <span class="number">true</span>
<span class="comment">// Set the highlight delegate. Note we must also set highlightFollowsCurrentItem</span>
<span class="comment">// to false so the highlight delegate can control how the highlight is moved.</span>
<span class="name">highlight</span>: <span class="name">highlightBar</span>
<span class="name">highlightFollowsCurrentItem</span>: <span class="number">false</span>
}</pre>
<a name="highlight-ranges"></a>
<h2 id="highlight-ranges">Highlight Ranges</h2>
<p><i>Highlight Ranges</i> shows the three different highlight range modes of <a href="qml-qtquick-listview.html">ListView</a>.</p>
<pre class="qml"><span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
<span class="name">id</span>: <span class="name">root</span>
property <span class="type">int</span> <span class="name">current</span>: <span class="number">0</span>
property <span class="type">bool</span> <span class="name">increasing</span>: <span class="number">true</span>
<span class="comment">// Example index automation for convenience, disabled on click or tap</span>
<span class="type"><a href="qml-qtquick-sequentialanimation.html">SequentialAnimation</a></span> {
<span class="name">id</span>: <span class="name">anim</span>
<span class="name">loops</span>: -<span class="number">1</span>
<span class="name">running</span>: <span class="number">true</span>
<span class="type"><a href="qml-qtquick-scriptaction.html">ScriptAction</a></span> {
<span class="name">script</span>: <span class="keyword">if</span> (<span class="name">increasing</span>) {
current++;
<span class="keyword">if</span> (<span class="name">current</span> <span class="operator">>=</span> <span class="name">aModel</span>.<span class="name">count</span> <span class="operator">-</span><span class="number">1</span>) {
<span class="name">current</span> <span class="operator">=</span> <span class="name">aModel</span>.<span class="name">count</span> <span class="operator">-</span> <span class="number">1</span>;
<span class="name">increasing</span> <span class="operator">=</span> !<span class="name">increasing</span>;
}
} <span class="keyword">else</span> {
current--;
<span class="keyword">if</span> (<span class="name">current</span> <span class="operator"><=</span> <span class="number">0</span>) {
<span class="name">current</span> <span class="operator">=</span> <span class="number">0</span>;
<span class="name">increasing</span> <span class="operator">=</span> !<span class="name">increasing</span>;
}
}
}
<span class="type"><a href="qml-qtquick-pauseanimation.html">PauseAnimation</a></span> { <span class="name">duration</span>: <span class="number">500</span> }
}
<span class="type"><a href="qml-qtquick-listview.html">ListView</a></span> {
<span class="name">id</span>: <span class="name">list1</span>
<span class="name">height</span>: <span class="number">50</span>; <span class="name">width</span>: <span class="name">parent</span>.<span class="name">width</span>
<span class="name">model</span>: <span class="name">PetsModel</span> {<span class="name">id</span>: <span class="name">aModel</span>}
<span class="name">delegate</span>: <span class="name">petDelegate</span>
<span class="name">orientation</span>: <span class="name">ListView</span>.<span class="name">Horizontal</span>
<span class="name">highlight</span>: <span class="name">Rectangle</span> { <span class="name">color</span>: <span class="string">"lightsteelblue"</span> }
<span class="name">currentIndex</span>: <span class="name">root</span>.<span class="name">current</span>
<span class="name">onCurrentIndexChanged</span>: <span class="name">root</span>.<span class="name">current</span> <span class="operator">=</span> <span class="name">currentIndex</span>
<span class="name">focus</span>: <span class="number">true</span>
}
<span class="type"><a href="qml-qtquick-listview.html">ListView</a></span> {
<span class="name">id</span>: <span class="name">list2</span>
<span class="name">y</span>: <span class="number">160</span>
<span class="name">height</span>: <span class="number">50</span>; <span class="name">width</span>: <span class="name">parent</span>.<span class="name">width</span>
<span class="name">model</span>: <span class="name">PetsModel</span> {}
<span class="name">delegate</span>: <span class="name">petDelegate</span>
<span class="name">orientation</span>: <span class="name">ListView</span>.<span class="name">Horizontal</span>
<span class="name">highlight</span>: <span class="name">Rectangle</span> { <span class="name">color</span>: <span class="string">"yellow"</span> }
<span class="name">currentIndex</span>: <span class="name">root</span>.<span class="name">current</span>
<span class="name">preferredHighlightBegin</span>: <span class="number">80</span>; <span class="name">preferredHighlightEnd</span>: <span class="number">220</span>
<span class="name">highlightRangeMode</span>: <span class="name">ListView</span>.<span class="name">ApplyRange</span>
}
<span class="type"><a href="qml-qtquick-listview.html">ListView</a></span> {
<span class="name">id</span>: <span class="name">list3</span>
<span class="name">y</span>: <span class="number">320</span>
<span class="name">height</span>: <span class="number">50</span>; <span class="name">width</span>: <span class="name">parent</span>.<span class="name">width</span>
<span class="name">model</span>: <span class="name">PetsModel</span> {}
<span class="name">delegate</span>: <span class="name">petDelegate</span>
<span class="name">orientation</span>: <span class="name">ListView</span>.<span class="name">Horizontal</span>
<span class="name">highlight</span>: <span class="name">Rectangle</span> { <span class="name">color</span>: <span class="string">"yellow"</span> }
<span class="name">currentIndex</span>: <span class="name">root</span>.<span class="name">current</span>
<span class="name">onCurrentIndexChanged</span>: <span class="name">root</span>.<span class="name">current</span> <span class="operator">=</span> <span class="name">currentIndex</span>
<span class="name">preferredHighlightBegin</span>: <span class="number">125</span>; <span class="name">preferredHighlightEnd</span>: <span class="number">125</span>
<span class="name">highlightRangeMode</span>: <span class="name">ListView</span>.<span class="name">StrictlyEnforceRange</span>
}
}</pre>
<a name="sections"></a>
<h2 id="sections">Sections</h2>
<p><i>Sections</i> demonstrates the various section headers and footers available to <a href="qml-qtquick-listview.html">ListView</a>.</p>
<pre class="qml"> <span class="comment">// The delegate for each section header</span>
<span class="type">Component</span> {
<span class="name">id</span>: <span class="name">sectionHeading</span>
<span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
<span class="name">width</span>: <span class="name">container</span>.<span class="name">width</span>
<span class="name">height</span>: <span class="name">childrenRect</span>.<span class="name">height</span>
<span class="name">color</span>: <span class="string">"lightsteelblue"</span>
<span class="type"><a href="qml-qtquick-text.html">Text</a></span> {
<span class="name">text</span>: <span class="name">section</span>
<span class="name">font</span>.bold: <span class="number">true</span>
<span class="name">font</span>.pixelSize: <span class="number">20</span>
}
}
}
<span class="type"><a href="qml-qtquick-listview.html">ListView</a></span> {
<span class="name">id</span>: <span class="name">view</span>
<span class="name">anchors</span>.top: <span class="name">parent</span>.<span class="name">top</span>
<span class="name">anchors</span>.bottom: <span class="name">buttonBar</span>.<span class="name">top</span>
<span class="name">width</span>: <span class="name">parent</span>.<span class="name">width</span>
<span class="name">model</span>: <span class="name">animalsModel</span>
<span class="name">delegate</span>: <span class="name">Text</span> { <span class="name">text</span>: <span class="name">name</span>; <span class="name">font</span>.pixelSize: <span class="number">18</span> }
<span class="name">section</span>.property: <span class="string">"size"</span>
<span class="name">section</span>.criteria: <span class="name">ViewSection</span>.<span class="name">FullString</span>
<span class="name">section</span>.delegate: <span class="name">sectionHeading</span>
}</pre>
<a name="packages"></a>
<h2 id="packages">Packages</h2>
<p><i>Packages</i> uses the Package type to transition delegates between two views.</p>
<p>It has a Package object which defines delegate items for each view and an item that can be transferred between delegates.</p>
<pre class="qml"><span class="type">Package</span> {
<span class="type"><a href="qml-qtquick-text.html">Text</a></span> { <span class="name">id</span>: <span class="name">listDelegate</span>; <span class="name">width</span>: <span class="name">parent</span>.<span class="name">width</span>; <span class="name">height</span>: <span class="number">25</span>; <span class="name">text</span>: <span class="string">'Empty'</span>; <span class="name">Package</span>.name: <span class="string">'list'</span> }
<span class="type"><a href="qml-qtquick-text.html">Text</a></span> { <span class="name">id</span>: <span class="name">gridDelegate</span>; <span class="name">width</span>: <span class="name">parent</span>.<span class="name">width</span> <span class="operator">/</span> <span class="number">2</span>; <span class="name">height</span>: <span class="number">50</span>; <span class="name">text</span>: <span class="string">'Empty'</span>; <span class="name">Package</span>.name: <span class="string">'grid'</span> }
<span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
<span class="name">id</span>: <span class="name">wrapper</span>
<span class="name">width</span>: <span class="name">parent</span>.<span class="name">width</span>; <span class="name">height</span>: <span class="number">25</span>
<span class="name">color</span>: <span class="string">'lightsteelblue'</span>
<span class="type"><a href="qml-qtquick-text.html">Text</a></span> { <span class="name">text</span>: <span class="name">display</span>; <span class="name">anchors</span>.centerIn: <span class="name">parent</span> }
<span class="name">state</span>: <span class="name">root</span>.<span class="name">upTo</span> <span class="operator">></span> <span class="name">index</span> ? <span class="string">'inGrid'</span> : <span class="string">'inList'</span>
<span class="name">states</span>: [
<span class="type"><a href="qml-qtquick-state.html">State</a></span> {
<span class="name">name</span>: <span class="string">'inList'</span>
<span class="type"><a href="qml-qtquick-parentchange.html">ParentChange</a></span> { <span class="name">target</span>: <span class="name">wrapper</span>; <span class="name">parent</span>: <span class="name">listDelegate</span> }
},
<span class="type"><a href="qml-qtquick-state.html">State</a></span> {
<span class="name">name</span>: <span class="string">'inGrid'</span>
<span class="type"><a href="qml-qtquick-parentchange.html">ParentChange</a></span> {
<span class="name">target</span>: <span class="name">wrapper</span>; <span class="name">parent</span>: <span class="name">gridDelegate</span>
<span class="name">x</span>: <span class="number">0</span>; <span class="name">y</span>: <span class="number">0</span>; <span class="name">width</span>: <span class="name">gridDelegate</span>.<span class="name">width</span>; <span class="name">height</span>: <span class="name">gridDelegate</span>.<span class="name">height</span>
}
}
]
<span class="name">transitions</span>: [
<span class="type"><a href="qml-qtquick-transition.html">Transition</a></span> {
<span class="type"><a href="qml-qtquick-parentanimation.html">ParentAnimation</a></span> {
<span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></span> { <span class="name">properties</span>: <span class="string">'x,y,width,height'</span>; <span class="name">duration</span>: <span class="number">300</span> }
}
}
]
}
}</pre>
<p>A DelegateModel allows the individual views to access their specific items from the shared package delegate.</p>
<pre class="qml"><span class="type">DelegateModel</span> {
<span class="name">id</span>: <span class="name">visualModel</span>
<span class="name">delegate</span>: <span class="name">Delegate</span> {}
<span class="name">model</span>: <span class="name">myModel</span>
}
<span class="type"><a href="qml-qtquick-listview.html">ListView</a></span> {
<span class="name">id</span>: <span class="name">lv</span>
<span class="name">height</span>: <span class="name">parent</span>.<span class="name">height</span><span class="operator">/</span><span class="number">2</span>
<span class="name">width</span>: <span class="name">parent</span>.<span class="name">width</span>
<span class="name">model</span>: <span class="name">visualModel</span>.<span class="name">parts</span>.<span class="name">list</span>
}
<span class="type"><a href="qml-qtquick-gridview.html">GridView</a></span> {
<span class="name">y</span>: <span class="name">parent</span>.<span class="name">height</span><span class="operator">/</span><span class="number">2</span>
<span class="name">height</span>: <span class="name">parent</span>.<span class="name">height</span><span class="operator">/</span><span class="number">2</span>
<span class="name">width</span>: <span class="name">parent</span>.<span class="name">width</span>
<span class="name">cellWidth</span>: <span class="name">width</span> <span class="operator">/</span> <span class="number">2</span>
<span class="name">cellHeight</span>: <span class="number">50</span>
<span class="name">model</span>: <span class="name">visualModel</span>.<span class="name">parts</span>.<span class="name">grid</span>
}</pre>
<a name="objectmodel"></a>
<h2 id="objectmodel">ObjectModel</h2>
<p><i>ObjectModel</i> uses an <a href="qtquick-views-example.html#objectmodel">ObjectModel</a> for the model instead of a <a href="qtquick-modelviewsdata-modelview.html#listmodel">ListModel</a>.</p>
<pre class="qml"> <span class="type">ObjectModel</span> {
<span class="name">id</span>: <span class="name">itemModel</span>
<span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
<span class="name">width</span>: <span class="name">view</span>.<span class="name">width</span>; <span class="name">height</span>: <span class="name">view</span>.<span class="name">height</span>
<span class="name">color</span>: <span class="string">"#FFFEF0"</span>
<span class="type"><a href="qml-qtquick-text.html">Text</a></span> { <span class="name">text</span>: <span class="string">"Page 1"</span>; <span class="name">font</span>.bold: <span class="number">true</span>; <span class="name">anchors</span>.centerIn: <span class="name">parent</span> }
<span class="name">Component</span>.onDestruction: <span class="keyword">if</span> (<span class="name">printDestruction</span>) <span class="name">print</span>(<span class="string">"destroyed 1"</span>)
}
<span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
<span class="name">width</span>: <span class="name">view</span>.<span class="name">width</span>; <span class="name">height</span>: <span class="name">view</span>.<span class="name">height</span>
<span class="name">color</span>: <span class="string">"#F0FFF7"</span>
<span class="type"><a href="qml-qtquick-text.html">Text</a></span> { <span class="name">text</span>: <span class="string">"Page 2"</span>; <span class="name">font</span>.bold: <span class="number">true</span>; <span class="name">anchors</span>.centerIn: <span class="name">parent</span> }
<span class="name">Component</span>.onDestruction: <span class="keyword">if</span> (<span class="name">printDestruction</span>) <span class="name">print</span>(<span class="string">"destroyed 2"</span>)
}
<span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
<span class="name">width</span>: <span class="name">view</span>.<span class="name">width</span>; <span class="name">height</span>: <span class="name">view</span>.<span class="name">height</span>
<span class="name">color</span>: <span class="string">"#F4F0FF"</span>
<span class="type"><a href="qml-qtquick-text.html">Text</a></span> { <span class="name">text</span>: <span class="string">"Page 3"</span>; <span class="name">font</span>.bold: <span class="number">true</span>; <span class="name">anchors</span>.centerIn: <span class="name">parent</span> }
<span class="name">Component</span>.onDestruction: <span class="keyword">if</span> (<span class="name">printDestruction</span>) <span class="name">print</span>(<span class="string">"destroyed 3"</span>)
}
}
<span class="type"><a href="qml-qtquick-listview.html">ListView</a></span> {
<span class="name">id</span>: <span class="name">view</span>
<span class="type">anchors</span> { <span class="name">fill</span>: <span class="name">parent</span>; <span class="name">bottomMargin</span>: <span class="number">30</span> }
<span class="name">model</span>: <span class="name">itemModel</span>
<span class="name">preferredHighlightBegin</span>: <span class="number">0</span>; <span class="name">preferredHighlightEnd</span>: <span class="number">0</span>
<span class="name">highlightRangeMode</span>: <span class="name">ListView</span>.<span class="name">StrictlyEnforceRange</span>
<span class="name">orientation</span>: <span class="name">ListView</span>.<span class="name">Horizontal</span>
<span class="name">snapMode</span>: <span class="name">ListView</span>.<span class="name">SnapOneItem</span>; <span class="name">flickDeceleration</span>: <span class="number">2000</span>
<span class="name">cacheBuffer</span>: <span class="number">200</span>
}</pre>
<a name="display-margins"></a>
<h2 id="display-margins">Display Margins</h2>
<p><i>Display Margins</i> uses delegates to display items and implements a simple header and footer components.</p>
<p>Files:</p>
<ul>
<li><a href="qtquick-views-views-qml.html">views/views.qml</a></li>
<li><a href="qtquick-views-gridview-gridview-example-qml.html">views/gridview/gridview-example.qml</a></li>
<li><a href="qtquick-views-listview-displaymargin-qml.html">views/listview/displaymargin.qml</a></li>
<li><a href="qtquick-views-listview-dynamiclist-qml.html">views/listview/dynamiclist.qml</a></li>
<li><a href="qtquick-views-listview-expandingdelegates-qml.html">views/listview/expandingdelegates.qml</a></li>
<li><a href="qtquick-views-listview-highlight-qml.html">views/listview/highlight.qml</a></li>
<li><a href="qtquick-views-listview-highlightranges-qml.html">views/listview/highlightranges.qml</a></li>
<li><a href="qtquick-views-listview-sections-qml.html">views/listview/sections.qml</a></li>
<li><a href="qtquick-views-listview-content-petsmodel-qml.html">views/listview/content/PetsModel.qml</a></li>
<li><a href="qtquick-views-listview-content-pressandholdbutton-qml.html">views/listview/content/PressAndHoldButton.qml</a></li>
<li><a href="qtquick-views-listview-content-recipesmodel-qml.html">views/listview/content/RecipesModel.qml</a></li>
<li><a href="qtquick-views-listview-content-smalltext-qml.html">views/listview/content/SmallText.qml</a></li>
<li><a href="qtquick-views-listview-content-textbutton-qml.html">views/listview/content/TextButton.qml</a></li>
<li><a href="qtquick-views-listview-content-togglebutton-qml.html">views/listview/content/ToggleButton.qml</a></li>
<li><a href="qtquick-views-objectmodel-objectmodel-qml.html">views/objectmodel/objectmodel.qml</a></li>
<li><a href="qtquick-views-package-delegate-qml.html">views/package/Delegate.qml</a></li>
<li><a href="qtquick-views-package-view-qml.html">views/package/view.qml</a></li>
<li><a href="qtquick-views-parallax-parallax-qml.html">views/parallax/parallax.qml</a></li>
<li><a href="qtquick-views-parallax-content-clock-qml.html">views/parallax/content/Clock.qml</a></li>
<li><a href="qtquick-views-parallax-content-parallaxview-qml.html">views/parallax/content/ParallaxView.qml</a></li>
<li><a href="qtquick-views-parallax-content-quitbutton-qml.html">views/parallax/content/QuitButton.qml</a></li>
<li><a href="qtquick-views-parallax-content-smiley-qml.html">views/parallax/content/Smiley.qml</a></li>
<li><a href="qtquick-views-parallax-content-pics-home-page-svg.html">views/parallax/content/pics/home-page.svg</a></li>
<li><a href="qtquick-views-pathview-pathview-example-qml.html">views/pathview/pathview-example.qml</a></li>
<li><a href="qtquick-views-visualdatamodel-dragselection-qml.html">views/visualdatamodel/dragselection.qml</a></li>
<li><a href="qtquick-views-visualdatamodel-slideshow-qml.html">views/visualdatamodel/slideshow.qml</a></li>
<li><a href="qtquick-views-main-cpp.html">views/main.cpp</a></li>
<li><a href="qtquick-views-views-pro.html">views/views.pro</a></li>
<li><a href="qtquick-views-views-qmlproject.html">views/views.qmlproject</a></li>
<li><a href="qtquick-views-views-qrc.html">views/views.qrc</a></li>
<li><a href="qtquick-views-visualdatamodel-visualdatamodel-qmlproject.html">views/visualdatamodel/visualdatamodel.qmlproject</a></li>
</ul>
</div>
<!-- @@@views -->
</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>
|