summaryrefslogtreecommitdiffstats
path: root/examples/scxml/calculator-qml/calculator-qml.qml
diff options
context:
space:
mode:
authorMichael Winkelmann <Michael.winkelmann@qt.io>2017-07-14 16:10:26 +0200
committerMichael Winkelmann <michael.winkelmann@qt.io>2017-09-11 14:37:00 +0000
commit16956a965817311fbc9d80ffbee74eb5d9ea00e0 (patch)
tree1e3b589163c52003bfa18778bac98bc9f2457628 /examples/scxml/calculator-qml/calculator-qml.qml
parenta1dff1a11ad303a1f82f181e6386194de90ec08f (diff)
QML code improvements for examples
Change-Id: I0f7bfc749e41071268d107d3250910de918a2d0a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'examples/scxml/calculator-qml/calculator-qml.qml')
-rw-r--r--examples/scxml/calculator-qml/calculator-qml.qml13
1 files changed, 8 insertions, 5 deletions
diff --git a/examples/scxml/calculator-qml/calculator-qml.qml b/examples/scxml/calculator-qml/calculator-qml.qml
index 386549e..c7d8236 100644
--- a/examples/scxml/calculator-qml/calculator-qml.qml
+++ b/examples/scxml/calculator-qml/calculator-qml.qml
@@ -79,8 +79,8 @@ Window {
color: "#46a2da"
Text {
id: resultText
- anchors.leftMargin: operations.implicitMargin
- anchors.rightMargin: operations.implicitMargin
+ anchors.leftMargin: buttons.implicitMargin
+ anchors.rightMargin: buttons.implicitMargin
anchors.fill: parent
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
@@ -93,7 +93,7 @@ Window {
}
Item {
- id: operations
+ id: buttons
anchors.top: resultArea.bottom
anchors.left: parent.left
anchors.right: parent.right
@@ -102,12 +102,13 @@ Window {
var ret = 0;
for (var i = 0; i < visibleChildren.length; ++i) {
var child = visibleChildren[i];
- ret += (child.implicitMargin || 0) / visibleChildren.length;
+ ret += (child.implicitMargin || 0);
}
- return ret;
+ return ret / visibleChildren.length;
}
Repeater {
+ id: operations
model: ["÷", "×", "+", "-"]
Button {
y: 0
@@ -130,6 +131,7 @@ Window {
}
Repeater {
+ id: digits
model: ["7", "8", "9", "4", "5", "6", "1", "2", "3", "0", ".", "C"]
Button {
x: (index % 3) * width
@@ -150,6 +152,7 @@ Window {
}
Button {
+ id: resultButton
x: 3 * width
y: parent.height / 5
textHeight: y - 2