qt-quick-for-designers-1:positioning_elements
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
qt-quick-for-designers-1:positioning_elements [2013/06/21 22:49] – created mithat | qt-quick-for-designers-1:positioning_elements [2013/07/06 22:52] (current) – mithat | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Positioning elements ====== | ====== Positioning elements ====== | ||
+ | ===== Absolute positioning ===== | ||
+ | {{youtube> | ||
+ | |||
+ | * You can define an item's position and size within its parent. | ||
+ | <file javascript basic-positioners.qml> | ||
import QtQuick 1.0 | import QtQuick 1.0 | ||
Line 8: | Line 13: | ||
Image { | Image { | ||
+ | anchors.fill: | ||
+ | source: " | ||
+ | } | ||
+ | |||
+ | Image { | ||
+ | id: spaceship | ||
+ | source: " | ||
+ | anchors.verticalCenter: | ||
+ | anchors.horizontalCenter: | ||
+ | } | ||
+ | }</ | ||
+ | |||
+ | ===== Relative positioning ===== | ||
+ | {{youtube> | ||
+ | * **Anchors** provide a way to position an item by specifying its relationship with other items. | ||
+ | <file javascript anchors-positioners.qml> | ||
+ | import QtQuick 1.0 | ||
+ | |||
+ | Item { | ||
+ | width: 400 | ||
+ | height: 400 | ||
+ | |||
+ | Image { | ||
+ | anchors.fill: | ||
source: " | source: " | ||
} | } | ||
Line 13: | Line 42: | ||
Spaceship { | Spaceship { | ||
id: spaceship | id: spaceship | ||
- | | + | |
- | | + | |
} | } | ||
}</ | }</ | ||
+ | ==== Multiple items ==== | ||
+ | {{youtube> | ||
+ | * Many ways to specify how an item is related to another: | ||
+ | * '' | ||
+ | <file javascript more-anchors-positioners.qml> | ||
+ | import QtQuick 1.0 | ||
+ | |||
+ | Item { | ||
+ | width: 400 | ||
+ | height: 400 | ||
+ | |||
+ | Image { | ||
+ | anchors.fill: | ||
+ | source: " | ||
+ | } | ||
+ | |||
+ | Image { | ||
+ | id: spaceship | ||
+ | source: " | ||
+ | anchors.verticalCenter: | ||
+ | anchors.horizontalCenter: | ||
+ | } | ||
+ | |||
+ | Image { | ||
+ | id: anotherSpaceship | ||
+ | source: " | ||
+ | scale: 0.5 | ||
+ | smooth: true | ||
+ | anchors.top: | ||
+ | anchors.right: | ||
+ | anchors.rightMargin: | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ====== Resources ====== | ||
+ | * {{: | ||
+ | * All source code is subject to this [[copyright header|copyright]]. |
qt-quick-for-designers-1/positioning_elements.1371854953.txt.gz · Last modified: 2013/06/21 22:49 by mithat