| 1 |
import QtQuick 2.0 |
| 2 |
|
| 3 |
// positioning all elements manually. |
| 4 |
Rectangle { |
| 5 |
id: p |
| 6 |
color: "red" |
| 7 |
width: 400 |
| 8 |
height: 800 |
| 9 |
|
| 10 |
Rectangle { |
| 11 |
id: c |
| 12 |
color: "blue" |
| 13 |
width: 400 |
| 14 |
height: 400 |
| 15 |
y: 400 |
| 16 |
|
| 17 |
Rectangle { |
| 18 |
id: n1 |
| 19 |
color: "green" |
| 20 |
width: 200 |
| 21 |
height: 100 |
| 22 |
x: 0 |
| 23 |
y: 200 |
| 24 |
} |
| 25 |
|
| 26 |
Rectangle { |
| 27 |
id: n2 |
| 28 |
color: "cyan" |
| 29 |
width: 200 |
| 30 |
height: 100 |
| 31 |
x: 200 |
| 32 |
y: 200 |
| 33 |
} |
| 34 |
|
| 35 |
Rectangle { |
| 36 |
id: n3 |
| 37 |
color: "aquamarine" |
| 38 |
width: 200 |
| 39 |
height: 100 |
| 40 |
x: 0 |
| 41 |
y: 300 |
| 42 |
} |
| 43 |
|
| 44 |
Rectangle { |
| 45 |
id: n4 |
| 46 |
color: "lightgreen" |
| 47 |
width: 200 |
| 48 |
height: 100 |
| 49 |
x: 200 |
| 50 |
y: 300 |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
// for visually determining correctness. |
| 55 |
//Timer { |
| 56 |
// property int count: 0 |
| 57 |
// interval: 1000 |
| 58 |
// running: true |
| 59 |
// repeat: true |
| 60 |
// onTriggered: { |
| 61 |
// if (count == 0) { |
| 62 |
// count = 1; |
| 63 |
// // expand |
| 64 |
// p.height = 800 |
| 65 |
// c.height = 400 |
| 66 |
// c.y = 400 |
| 67 |
// n1.height = 100 |
| 68 |
// n1.y = 200 |
| 69 |
// n2.height = 100 |
| 70 |
// n2.y = 200 |
| 71 |
// n3.height = 100 |
| 72 |
// n3.y = 300 |
| 73 |
// n4.height = 100 |
| 74 |
// n4.y = 300 |
| 75 |
// } else { |
| 76 |
// count = 0; |
| 77 |
// // shrink |
| 78 |
// p.height = 400 |
| 79 |
// c.height = 200 |
| 80 |
// c.y = 200 |
| 81 |
// n1.height = 50 |
| 82 |
// n1.y = 100 |
| 83 |
// n2.height = 50 |
| 84 |
// n2.y = 100 |
| 85 |
// n3.height = 50 |
| 86 |
// n3.y = 150 |
| 87 |
// n4.height = 50 |
| 88 |
// n4.y = 150 |
| 89 |
// } |
| 90 |
// } |
| 91 |
//} |
| 92 |
|
| 93 |
Component.onCompleted: { |
| 94 |
var iterations = 10000; |
| 95 |
//var t0 = new Date(); |
| 96 |
while (iterations > 0) { |
| 97 |
iterations--; |
| 98 |
// expand |
| 99 |
p.height = 800 |
| 100 |
c.height = 400 |
| 101 |
c.y = 400 |
| 102 |
n1.height = 100 |
| 103 |
n1.y = 200 |
| 104 |
n2.height = 100 |
| 105 |
n2.y = 200 |
| 106 |
n3.height = 100 |
| 107 |
n3.y = 300 |
| 108 |
n4.height = 100 |
| 109 |
n4.y = 300 |
| 110 |
// shrink |
| 111 |
p.height = 400 |
| 112 |
c.height = 200 |
| 113 |
c.y = 200 |
| 114 |
n1.height = 50 |
| 115 |
n1.y = 100 |
| 116 |
n2.height = 50 |
| 117 |
n2.y = 100 |
| 118 |
n3.height = 50 |
| 119 |
n3.y = 150 |
| 120 |
n4.height = 50 |
| 121 |
n4.y = 150 |
| 122 |
} |
| 123 |
//var t1 = new Date(); |
| 124 |
//console.log("Absolute Positioning: " + (t1.valueOf() - t0.valueOf()) + " milliseconds"); |
| 125 |
} |
| 126 |
} |