1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the examples of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:BSD$
10 ** You may use this file under the terms of the BSD license as follows:
12 ** "Redistribution and use in source and binary forms, with or without
13 ** modification, are permitted provided that the following conditions are
15 ** * Redistributions of source code must retain the above copyright
16 ** notice, this list of conditions and the following disclaimer.
17 ** * Redistributions in binary form must reproduce the above copyright
18 ** notice, this list of conditions and the following disclaimer in
19 ** the documentation and/or other materials provided with the
21 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
22 ** the names of its contributors may be used to endorse or promote
23 ** products derived from this software without specific prior written
26 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
39 ****************************************************************************/
45 property bool mirror: Qt.application.layoutDirection == Qt.RightToLeft
46 LayoutMirroring.enabled: mirror
47 LayoutMirroring.childrenInherit: true
50 color: "lightsteelblue"
54 anchors { left: parent.left; right: parent.right; top: parent.top; margins: 10 }
58 anchors.left: parent.left
64 anchors.left: parent.left
68 property string text: "THISISROW"
69 anchors.left: parent.left
71 model: parent.text.length
72 delegate: positionerDelegate
79 property string text: "THISISFLOW"
80 anchors.left: parent.left
82 model: parent.text.length
83 delegate: positionerDelegate
90 property string text: "THISISGRID"
91 anchors.left: parent.left
93 model: parent.text.length
94 delegate: positionerDelegate
98 id: positionerDelegate
102 text: parent.text[index]
114 text: "Text alignment"
115 anchors.left: parent.left
123 anchors.left: parent.left
127 anchors { fill: parent; margins: 5 }
141 text: "Text aligned to left"
142 horizontalAlignment: Text.AlignLeft
147 text: "Text aligned to right"
148 horizontalAlignment: Text.AlignRight
155 anchors.left: parent.left
161 anchors.left: parent.left
167 width: 360; height: 45
168 orientation: Qt.Horizontal
169 property string text: "LISTVIEWLISTVIEWLISTVIEWLISTVIEWLISTVIEWLISTVIEW"
170 delegate: Rectangle {
172 width: 45; height: 45
174 anchors { fill: parent; margins: 1 }
178 text: listView.text[index]
180 anchors.centerIn: parent
189 width: 180; height: 90
190 cellWidth: 45; cellHeight: 45
191 property string text: "GRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEW"
192 anchors.left: parent.left
193 delegate: Rectangle {
195 width: 45; height: 45
197 anchors { fill: parent; margins: 1 }
201 anchors.centerIn: parent
203 text: gridView.text[index]
211 anchors.left: parent.left
215 color: Qt.rgba(0.2, 0.2, 0.2, 0.6)
216 width: 275; height: 95
217 anchors.left: parent.left
220 width: 130; height: 40
222 text: "Item with x: 5\n(not mirrored)"
223 anchors.centerIn: parent
227 color: Qt.rgba(0.7, 0.7, 0.7)
229 width: 130; height: 40
230 function mirror(value) {
231 return LayoutMirroring.enabled ? (parent.width - width - value) : value;
234 text: "Item with x: " + parent.x + "\n(manually mirrored)"
235 anchors.centerIn: parent
241 anchors.left: parent.left
246 color: Qt.rgba(0.2, 0.2, 0.2, 0.6)
247 width: 270; height: 170
248 anchors.left: parent.left
252 width: 180; height: 90
253 anchors { horizontalCenter: parent.horizontalCenter; horizontalCenterOffset: 30 }
255 text: "Horizontal center anchored\nwith offset 30\nto the horizontal center\nof the parent."
257 anchors.centerIn: parent
263 width: 120; height: 70
264 anchors { left: parent.left; bottom: parent.bottom }
266 text: "Left side anchored\nto the left side\nof the parent."
268 anchors.centerIn: parent
273 color: Qt.rgba(0.7, 0.7, 0.7)
274 width: 140; height: 90
275 anchors { right: parent.right; bottom: parent.bottom }
277 text: "Right side anchored\nto the right side\nof the parent."
278 anchors.centerIn: parent
284 color: mouseArea2.pressed ? "black" : "gray"
285 height: 50; width: parent.width
286 anchors.left: parent.left
288 anchors.centerIn: parent
290 text: root.mirror ? "Mirrored" : "Not mirrored"
293 anchors.horizontalCenter: parent.horizontalCenter
296 text: "(click here to toggle)"
300 anchors.horizontalCenter: parent.horizontalCenter
307 root.mirror = !root.mirror;