/usr/share/qt5/doc/qtdoc/qtquick-usecase-layouts.html is in qt5-doc-html 5.3.2-3.
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 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.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" />
<!-- layouts.qdoc -->
<title>Use Case - Positioners and Layouts In QML | QtDoc 5.3</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><a href="index.html">Qt 5.3</a></li>
<li>Use Case - Positioners and Layouts In QML</li>
<li id="buildversion">
Qt 5.3.2 Reference Documentation</li>
</ul>
</div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#manual-positioning">Manual Positioning</a></li>
<li class="level1"><a href="#anchors">Anchors</a></li>
<li class="level1"><a href="#positioners-and-layouts">Positioners and Layouts</a></li>
</ul>
</div>
<h1 class="title">Use Case - Positioners and Layouts In QML</h1>
<span class="subtitle"></span>
<!-- $$$qtquick-usecase-layouts.html-description -->
<div class="descr"> <a name="details"></a>
<p>There are several ways to position items in QML.</p>
<p>Below is a brief overview. For more details, see <a href="../qtquick/qtquick-positioning-topic.html">Important Concepts In Qt Quick - Positioning</a>.</p>
<a name="manual-positioning"></a>
<h2>Manual Positioning</h2>
<p>Items can be placed at specific x,y coordinates on the screen by setting their x,y properties. This will setup their position relative to the top left corner of their parent, according to the <a href="../qtquick/qtquick-visualcanvas-coordinates.html">visual coordinate system</a> rules.</p>
<p>Combined with using <a href="../qtqml/qtqml-syntax-propertybinding.html">bindings</a> instead of constant valudes for these properties, relative positioning is also easily accomplished by setting the x and y coordinates to the appropriate bindings.</p>
<pre class="qml">import QtQuick 2.3
<span class="type"><a href="../qtquick/qml-qtquick-item.html">Item</a></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="../qtquick/qml-qtquick-rectangle.html">Rectangle</a></span> {
<span class="comment">// Manually positioned at 20,20</span>
<span class="name">x</span>: <span class="number">20</span>
<span class="name">y</span>: <span class="number">20</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">"red"</span>
}
}</pre>
<p class="centerAlign"><img src="images/qml-uses-layouts-direct.png" alt="" /></p><a name="anchors"></a>
<h2>Anchors</h2>
<p>The <tt>Item</tt> type provides the abilitiy to anchor to other <a href="../qtquick/qml-qtquick-item.html">Item</a> types. There are six anchor lines for each item: <i>left</i>, <i>right</i>, <i>vertical center</i>, <i>top</i>, <i>bottom</i> and <i>horizontal center</i>. The three vertical anchor lines can be anchored to any of the three vertical anchor lines of another item, and the three horizontal anchor lines can be anchored to the horizontal anchor lines of another item.</p>
<p>For full details, see <a href="../qtquick/qtquick-positioning-anchors.html">Positioning with Anchors</a> and the documentation of the <a href="../qtquick/qml-qtquick-item.html#anchors.top-prop">anchors property</a>.</p>
<pre class="qml">import QtQuick 2.3
<span class="type"><a href="../qtquick/qml-qtquick-item.html">Item</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"><a href="../qtquick/qml-qtquick-rectangle.html">Rectangle</a></span> {
<span class="comment">// Anchored to 20px off the top right corner of the parent</span>
<span class="name">anchors</span>.right: <span class="name">parent</span>.<span class="name">right</span>
<span class="name">anchors</span>.top: <span class="name">parent</span>.<span class="name">top</span>
<span class="name">anchors</span>.margins: <span class="number">20</span> <span class="comment">// Sets all margins at once</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">"orange"</span>
}
<span class="type"><a href="../qtquick/qml-qtquick-rectangle.html">Rectangle</a></span> {
<span class="comment">// Anchored to 20px off the top center corner of the parent.</span>
<span class="comment">// Notice the different group property syntax for 'anchors' compared to</span>
<span class="comment">// the previous Rectangle. Both are valid.</span>
<span class="type">anchors</span> { <span class="name">horizontalCenter</span>: <span class="name">parent</span>.<span class="name">horizontalCenter</span>; <span class="name">top</span>: <span class="name">parent</span>.<span class="name">top</span>; <span class="name">topMargin</span>: <span class="number">20</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">"green"</span>
}
}</pre>
<p class="centerAlign"><img src="images/qml-uses-layouts-anchors.png" alt="" /></p><a name="positioners-and-layouts"></a>
<h2>Positioners and Layouts</h2>
<p>For the common case of wanting to <i>position</i> a set of types in a regular pattern, Qt Quick provides some positioner types. Items placed in a positioner are automatically positioned in some way; for example, a <a href="../qtquick/qml-qtquick-row.html">Row</a> positions items to be horizontally adjacent (forming a row).</p>
<p>For full details see <a href="../qtquick/qtquick-positioning-layouts.html">Item Positioners</a> and the documentation for <a href="../qtquick/qtquick-qmltypereference.html">the positioner types</a>.</p>
<pre class="qml">import QtQuick 2.3
<span class="type"><a href="../qtquick/qml-qtquick-item.html">Item</a></span> {
<span class="name">width</span>: <span class="number">300</span>; <span class="name">height</span>: <span class="number">100</span>
<span class="type"><a href="../qtquick/qml-qtquick-row.html">Row</a></span> { <span class="comment">// The "Row" type lays out its child items in a horizontal line</span>
<span class="name">spacing</span>: <span class="number">20</span> <span class="comment">// Places 20px of space between items</span>
<span class="type"><a href="../qtquick/qml-qtquick-rectangle.html">Rectangle</a></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">"red"</span> }
<span class="type"><a href="../qtquick/qml-qtquick-rectangle.html">Rectangle</a></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">"green"</span> }
<span class="type"><a href="../qtquick/qml-qtquick-rectangle.html">Rectangle</a></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">"blue"</span> }
}
}</pre>
<p class="centerAlign"><img src="images/qml-uses-layouts-positioners.png" alt="" /></p><p>If <i>positioning and resizing</i> is desired, you can use the layouts in <a href="../qtquicklayouts/qtquicklayouts-index.html">Qt Quick Layouts</a>.</p>
</div>
<!-- @@@qtquick-usecase-layouts.html -->
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2014 Digia Plc and/or its
subsidiaries. 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> Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. </p>
</div>
</body>
</html>
|