From 7af1c2dc0e160652a9583cf1798720cd0f3d72f8 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 8 Oct 2015 10:06:06 +0200 Subject: Give SquareButton types a side property to mediate being square. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ƶ --- src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc | 8 +++++--- src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc | 3 ++- src/qml/doc/src/qmllanguageref/syntax/signals.qdoc | 3 ++- 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 -- cgit v1.2.3