| 1 |
import QtQuick 2.0 |
| 2 |
|
| 3 |
// positioning via anchors contaminated with a binding |
| 4 |
Rectangle { |
| 5 |
id: p |
| 6 |
color: "red" |
| 7 |
width: 400 |
| 8 |
height: 800 |
| 9 |
|
| 10 |
Rectangle { |
| 11 |
id: c |
| 12 |
color: "blue" |
| 13 |
anchors.top: p.verticalCenter |
| 14 |
anchors.bottom: p.bottom |
| 15 |
anchors.left: p.left |
| 16 |
anchors.right: p.right |
| 17 |
|
| 18 |
Rectangle { |
| 19 |
id: n1 |
| 20 |
color: "green" |
| 21 |
height: c.height / 4 |
| 22 |
anchors.top: c.verticalCenter |
| 23 |
anchors.left: c.left |
| 24 |
anchors.right: c.horizontalCenter |
| 25 |
} |
| 26 |
|
| 27 |
Rectangle { |
| 28 |
id: n2 |
| 29 |
color: "cyan" |
| 30 |
anchors.top: c.verticalCenter |
| 31 |
anchors.bottom: n1.bottom |
| 32 |
anchors.left: c.horizontalCenter |
| 33 |
anchors.right: c.right |
| 34 |
} |
| 35 |
|
| 36 |
Rectangle { |
| 37 |
id: n3 |
| 38 |
color: "aquamarine" |
| 39 |
anchors.top: n1.bottom |
| 40 |
anchors.bottom: c.bottom |
| 41 |
anchors.left: c.left |
| 42 |
anchors.right: c.horizontalCenter |
| 43 |
} |
| 44 |
|
| 45 |
Rectangle { |
| 46 |
id: n4 |
| 47 |
color: "lightgreen" |
| 48 |
anchors.top: n1.bottom |
| 49 |
anchors.bottom: c.bottom |
| 50 |
anchors.left: c.horizontalCenter |
| 51 |
anchors.right: c.right |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
// for visually determining correctness. |
| 56 |
//Timer { |
| 57 |
// property int count: 0 |
| 58 |
// interval: 1000 |
| 59 |
// running: true |
| 60 |
// repeat: true |
| 61 |
// onTriggered: { |
| 62 |
// if (count == 0) { |
| 63 |
// count = 1; |
| 64 |
// p.height = 800; |
| 65 |
// } else { |
| 66 |
// count = 0; |
| 67 |
// p.height = 400; |
| 68 |
// } |
| 69 |
// } |
| 70 |
//} |
| 71 |
|
| 72 |
Component.onCompleted: { |
| 73 |
p.height = 800; |
| 74 |
p.height = 400; |
| 75 |
} |
| 76 |
} |