diff options
author | Edward Welbourne <edward.welbourne@theqtcompany.com> | 2015-10-08 10:06:06 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2016-09-21 15:09:06 +0000 |
commit | 7af1c2dc0e160652a9583cf1798720cd0f3d72f8 (patch) | |
tree | e2ddb560a5d6347cf3c0b4846e8cc8c654a949f5 /src | |
parent | a273a0ad9c1df7aed612ee6353753f668d545076 (diff) |
Give SquareButton types a side property to mediate being square.
We shouldn't be setting width and height for each square; we should
only need to set their side, which determines their width and height -
so that they're actually square !
More pertinently, this could later serve as an illustration of how to
use properties and bindings. Ideally, we'd do this in some way that
actually ensures setting width or height changes side; but the simple
approach will do for now.
Change-Id: I0df89e11221dde5d1d2930c4a779b59cf0d46654
Reviewed-by: Topi Reiniƶ <topi.reinio@theqtcompany.com>
Diffstat (limited to 'src')
3 files changed, 9 insertions, 5 deletions
diff --git a/src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc b/src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc index 4b4b25796c..03a7ddfb19 100644 --- a/src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc +++ b/src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc @@ -43,7 +43,8 @@ For example, below is a document that declares a \l Rectangle with a child \l Mo import QtQuick 2.0 Rectangle { - width: 100; height: 100 + property int side: 100 + width: side; height: side color: "red" MouseArea { @@ -87,7 +88,7 @@ For example, the root object type in the \c SquareButton.qml file above is \l Re import QtQuick 2.0 Column { - SquareButton { width: 50; height: 50 } + SquareButton { side: 50 } SquareButton { x: 50; color: "blue" } SquareButton { radius: 10 } } @@ -112,7 +113,8 @@ Rectangle { root.color = Qt.rgba(Math.random(), Math.random(), Math.random(), 1) } - width: 100; height: 100 + property int side: 100 + width: side; height: side color: "red" MouseArea { diff --git a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc index b0e262d2b9..b136a0e92f 100644 --- a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc +++ b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc @@ -724,7 +724,8 @@ Rectangle { signal activated(real xPosition, real yPosition) signal deactivated - width: 100; height: 100 + property int side: 100 + width: side; height: side MouseArea { anchors.fill: parent diff --git a/src/qml/doc/src/qmllanguageref/syntax/signals.qdoc b/src/qml/doc/src/qmllanguageref/syntax/signals.qdoc index 602b202ed4..4a022f2b0b 100644 --- a/src/qml/doc/src/qmllanguageref/syntax/signals.qdoc +++ b/src/qml/doc/src/qmllanguageref/syntax/signals.qdoc @@ -187,7 +187,8 @@ Rectangle { signal activated(real xPosition, real yPosition) - width: 100; height: 100 + property int side: 100 + width: side; height: side MouseArea { anchors.fill: parent |