aboutsummaryrefslogtreecommitdiffstats
path: root/examples/declarative/positioners/positioners-attachedproperties.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/positioners/positioners-attachedproperties.qml')
-rw-r--r--examples/declarative/positioners/positioners-attachedproperties.qml66
1 files changed, 66 insertions, 0 deletions
diff --git a/examples/declarative/positioners/positioners-attachedproperties.qml b/examples/declarative/positioners/positioners-attachedproperties.qml
new file mode 100644
index 0000000000..49638683e4
--- /dev/null
+++ b/examples/declarative/positioners/positioners-attachedproperties.qml
@@ -0,0 +1,66 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 400
+ height: 100
+
+ // Create row with four rectangles, the fourth one is hidden
+ Row {
+ id: row
+
+ Rectangle {
+ id: red
+ color: "red"
+ width: 100
+ height: 100
+
+ // When mouse is clicked, display the values of the positioner
+ MouseArea {
+ anchors.fill: parent
+ onClicked: row.showInfo(red.Positioner)
+ }
+ }
+
+ Rectangle {
+ id: green
+ color: "green"
+ width: 100
+ height: 100
+
+ // When mouse is clicked, display the values of the positioner
+ MouseArea {
+ anchors.fill: parent
+ onClicked: row.showInfo(green.Positioner)
+ }
+ }
+
+ Rectangle {
+ id: blue
+ color: "blue"
+ width: 100
+ height: 100
+
+ // When mouse is clicked, display the values of the positioner
+ MouseArea {
+ anchors.fill: parent
+ onClicked: row.showInfo(blue.Positioner)
+ }
+ }
+
+ // This rectangle is not visible, so it doesn't have a positioner value
+ Rectangle {
+ color: "black"
+ width: 100
+ height: 100
+ visible: false
+ }
+
+ // Print the index of the child item in the positioner and convenience
+ // properties showing if it's the first or last item.
+ function showInfo(positioner) {
+ console.log("Item Index = " + positioner.index)
+ console.log(" isFirstItem = " + positioner.isFirstItem)
+ console.log(" isLastItem = " + positioner.isLastItem)
+ }
+ }
+}