diff options
author | Chris Adams <christopher.adams@nokia.com> | 2012-07-06 18:36:01 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-13 09:05:06 +0200 |
commit | 60a13ee3fd021080d92a11b3456602103ad61a79 (patch) | |
tree | 346da0c9cebd5fdac2d796cd56b6ccb08f26042f /src/qml/doc/src/syntax/propertybinding.qdoc | |
parent | 867704b37cfbe055ba947291cde343204ce8e52a (diff) |
Improve object attributes documentation
There is no conceptual difference between custom attributes
(custom properties, signals and methods defined in QML object
declarations) and non-custom attributes (defined in C++).
This change coalesces the documentation for the different attribute
types, and also fixes some line wrapping issues.
Change-Id: I8cb8d71025e873523cb4389827eef7967e49a626
Reviewed-by: Bea Lam <bea.lam@nokia.com>
Diffstat (limited to 'src/qml/doc/src/syntax/propertybinding.qdoc')
-rw-r--r-- | src/qml/doc/src/syntax/propertybinding.qdoc | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/qml/doc/src/syntax/propertybinding.qdoc b/src/qml/doc/src/syntax/propertybinding.qdoc index 418a080947..1f529b3f2d 100644 --- a/src/qml/doc/src/syntax/propertybinding.qdoc +++ b/src/qml/doc/src/syntax/propertybinding.qdoc @@ -52,25 +52,33 @@ Rectangle { Whenever the \c height of the parent item changes, the \c height of the blue rectangle will update to be of the same value. -The binding expression can be any valid JavaScript expression. For example, the above code could be modified so that the height of the rectangle is always one-third of the height of its parent: +Furthermore, a binding can contain any valid JavaScript expression or +statement, as QML uses a standards compliant JavaScript engine. Below are +valid bindings that could be substituted for the \c height binding from the +above example: -\qml -Rectangle { - width: 200; height: 200 +\code +height: parent.height / 2 - Rectangle { - width: 100; height: parent.height / 3 - color: "blue" - } +height: Math.min(parent.width, parent.height) + +height: parent.height > 100 ? parent.height : parent.height/2 + +height: { + if (parent.height > 100) + return parent.height + else + return parent.height / 2 } -\endqml + +height: someMethodThatReturnsHeight() +\endcode ###TODO have .gif here that demonstrates the changes? Whenever the value of \c parent.height changes, the QML engine will re-evaluate the above expression and assign the blue rectangle's \c width property with the appropriate updated value. - -QML uses a standards compliant JavaScript engine, so any valid JavaScript expression or statement can be used in a property binding. Bindings can access object properties, call methods and use built-in JavaScript objects such as \c Date and \c Math. Here is an example with various valid bindings: +Bindings can access object properties, call methods and use built-in JavaScript objects such as \c Date and \c Math. Here is an example with various valid bindings: \qml Column { |