<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- positioners.qdoc --> <title>Qt Quick Examples - Positioners | Qt Quick 5.9</title> <link rel="stylesheet" type="text/css" href="style/offline-simple.css" /> <script type="text/javascript"> document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css"); // loading style sheet breaks anchors that were jumped to before // so force jumping to anchor again setTimeout(function() { var anchor = location.hash; // need to jump to different anchor first (e.g. none) location.hash = "#"; setTimeout(function() { location.hash = anchor; }, 0); }, 0); </script> </head> <body> <div class="header" id="qtdocheader"> <div class="main"> <div class="main-rounded"> <div class="navigationbar"> <table><tr> <td >Qt 5.9</td><td ><a href="qtquick-index.html">Qt Quick</a></td><td >Qt Quick Examples - Positioners</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td> </tr></table> </div> </div> <div class="content"> <div class="line"> <div class="content mainContent"> <div class="sidebar"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#running-the-example">Running the Example</a></li> <li class="level1"><a href="#transitions">Transitions</a></li> <li class="level1"><a href="#attached-properties">Attached Properties</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">Qt Quick Examples - Positioners</h1> <span class="subtitle"></span> <!-- $$$positioners-description --> <div class="descr"> <a name="details"></a> <p class="centerAlign"><img src="images/qml-positioners-example.png" alt="" /></p><p><i>Positioners</i> is a collection of small QML examples relating to positioners. Each example is a small QML file emphasizing a particular type or feature. For more information, visit <a href="qtquick-positioning-topic.html">Important Concepts In Qt Quick - Positioning</a>.</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="transitions"></a> <h2 id="transitions">Transitions</h2> <p><i>Transitions</i> shows animated transitions when showing or hiding items in a positioner. It consists of a scene populated with items in a variety of positioners: <a href="qtquick-positioning-layouts.html#column">Column</a>, <a href="qtquick-positioning-layouts.html#row">Row</a>, <a href="qtquick-positioning-layouts.html#grid">Grid</a>, and <a href="qtquick-positioning-layouts.html#flow">Flow</a>. Each positioner has animations described as Transitions.</p> <pre class="qml"> <span class="name">move</span>: <span class="name">Transition</span> { <span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></span> { <span class="name">properties</span>: <span class="string">"x,y"</span>; <span class="name">easing</span>.type: <span class="name">Easing</span>.<span class="name">OutBounce</span> } } </pre> <p>The move transition specifies how items inside a positioner will animate when they are displaced by the appearance or disappearance of other items.</p> <pre class="qml"> <span class="name">add</span>: <span class="name">Transition</span> { <span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></span> { <span class="name">properties</span>: <span class="string">"x,y"</span>; <span class="name">easing</span>.type: <span class="name">Easing</span>.<span class="name">OutBounce</span> } } </pre> <p>The add transition specifies how items will appear when they are added to a positioner.</p> <pre class="qml"> <span class="name">populate</span>: <span class="name">Transition</span> { <span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></span> { <span class="name">properties</span>: <span class="string">"x,y"</span>; <span class="name">from</span>: <span class="number">200</span>; <span class="name">duration</span>: <span class="number">100</span>; <span class="name">easing</span>.type: <span class="name">Easing</span>.<span class="name">OutBounce</span> } } </pre> <p>The populate transition specifies how items will appear when their parent positioner is first created.</p> <a name="attached-properties"></a> <h2 id="attached-properties">Attached Properties</h2> <p><i>Attached Properties</i> shows how the Positioner attached property can be used to determine where an item is within a positioner.</p> <pre class="qml"> <span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> { <span class="name">id</span>: <span class="name">green</span> <span class="name">color</span>: <span class="string">"#80c342"</span> <span class="name">width</span>: <span class="number">100</span> <span class="operator">*</span> <span class="name">page</span>.<span class="name">ratio</span> <span class="name">height</span>: <span class="number">100</span> <span class="operator">*</span> <span class="name">page</span>.<span class="name">ratio</span> <span class="type"><a href="qml-qtquick-text.html">Text</a></span> { <span class="name">anchors</span>.left: <span class="name">parent</span>.<span class="name">right</span> <span class="name">anchors</span>.leftMargin: <span class="number">20</span> <span class="name">anchors</span>.verticalCenter: <span class="name">parent</span>.<span class="name">verticalCenter</span> <span class="name">text</span>: <span class="string">"Index: "</span> <span class="operator">+</span> <span class="name">parent</span>.<span class="name">Positioner</span>.<span class="name">index</span> <span class="operator">+</span> (<span class="name">parent</span>.<span class="name">Positioner</span>.<span class="name">isFirstItem</span> ? <span class="string">" (First)"</span> : <span class="string">""</span>) <span class="operator">+</span> (<span class="name">parent</span>.<span class="name">Positioner</span>.<span class="name">isLastItem</span> ? <span class="string">" (Last)"</span> : <span class="string">""</span>) } <span class="comment">// When mouse is clicked, display the values of the positioner</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">column</span>.<span class="name">showInfo</span>(<span class="name">green</span>.<span class="name">Positioner</span>) } } </pre> <p>Files:</p> <ul> <li><a href="qtquick-positioners-positioners-attachedproperties-qml.html">positioners/positioners-attachedproperties.qml</a></li> <li><a href="qtquick-positioners-positioners-transitions-qml.html">positioners/positioners-transitions.qml</a></li> <li><a href="qtquick-positioners-positioners-qml.html">positioners/positioners.qml</a></li> <li><a href="qtquick-positioners-main-cpp.html">positioners/main.cpp</a></li> <li><a href="qtquick-positioners-positioners-pro.html">positioners/positioners.pro</a></li> <li><a href="qtquick-positioners-positioners-qmlproject.html">positioners/positioners.qmlproject</a></li> <li><a href="qtquick-positioners-positioners-qrc.html">positioners/positioners.qrc</a></li> </ul> </div> <!-- @@@positioners --> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2017 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.<br> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. </p> </div> </body> </html>