diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-04-20 05:15:44 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-04-20 05:15:44 (GMT) |
commit | 3f37769fffe250fc9ec65c725e05fefe9c85c08a (patch) | |
tree | f6e872581ddbef8f647ec2131b915cd5ea15a788 /doc | |
parent | 2801cc86b442e3a1256e48ffdf6dd92ffeb74a17 (diff) | |
parent | 78c78085449149b5c48bbecd49424974cdf79bee (diff) | |
download | Qt-3f37769fffe250fc9ec65c725e05fefe9c85c08a.zip Qt-3f37769fffe250fc9ec65c725e05fefe9c85c08a.tar.gz Qt-3f37769fffe250fc9ec65c725e05fefe9c85c08a.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'doc')
-rw-r--r-- | doc/src/declarative/propertybinding.qdoc | 56 | ||||
-rw-r--r-- | doc/src/getting-started/examples.qdoc | 1 |
2 files changed, 46 insertions, 11 deletions
diff --git a/doc/src/declarative/propertybinding.qdoc b/doc/src/declarative/propertybinding.qdoc index 02f9868..ab3682d 100644 --- a/doc/src/declarative/propertybinding.qdoc +++ b/doc/src/declarative/propertybinding.qdoc @@ -78,16 +78,52 @@ Rectangle { } \endcode -Being JavaScript expressions, bindings are evaluated in a scope chain. The \l {QML Scope} -documentation covers the specifics of scoping in QML. - -\list -\o When does a binding not get updated? -\o Scope -\o Assigning a constant/other binding clears existing binding -\o Loops -\o Using model data -\endlist +While syntactically bindings can be of arbitrary complexity, if a binding starts to become +overly complex - such as involving multiple lines, or imperative loops - it may be better +to refactor the component entirely, or at least factor the binding out into a separate +function. + +\section1 Changing Bindings + +The \l PropertyChanges element can be used within a state change to modify the bindings on +properties. + +This example modifies the \l Rectangle's width property binding to be \c {otherItem.height} +when in the "square" state. When it returns to its default state, width's original property +binding will have been restored. + +\code +Rectangle { + id: rectangle + width: otherItem.width + height: otherItem.height + + states: State { + name: "square" + PropertyChanges { + target: rectangle + width: otherItem.height + } + } +} +\endcode + +Imperatively assigning a value directly to a property will also implicitly remove a binding +on a property. A property can only have one value at a time, and if code explicitly sets +this value the binding must be removed. The \l Rectangle in the example below will have +a width of 13, regardless of the otherItem's width. + +\code +Rectangle { + width: otherItem.width + + Component.onCompleted: { + width = 13; + } +} +\endcode + +There is no way to create a property binding directly from imperative JavaScript code. \section1 Binding Element diff --git a/doc/src/getting-started/examples.qdoc b/doc/src/getting-started/examples.qdoc index 9ddafc4..071a107 100644 --- a/doc/src/getting-started/examples.qdoc +++ b/doc/src/getting-started/examples.qdoc @@ -159,7 +159,6 @@ \endfloat The Qt Declarative module provides a declarative framework for building highly dynamic, custom user interfaces. - classes. \clearfloat \section1 \l{Painting Examples}{Painting} |