From f9d897b03cd6919bbac1205fc90a09354b31f286 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Tue, 1 Nov 2011 16:54:47 +1000 Subject: [PATCH] Fix documentation for property var Previously, it was not clear that a binding which accesses a property of a JavaScript Objects assigned to a var property would not be re-evaluated if the value of the property changed. Change-Id: I72d990e05104bc452fc516511a14716b2913ff9a Reviewed-by: Martin Jones --- doc/src/declarative/basictypes.qdoc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/doc/src/declarative/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc index 1bc1373..5e4ce9a 100644 --- a/doc/src/declarative/basictypes.qdoc +++ b/doc/src/declarative/basictypes.qdoc @@ -449,21 +449,22 @@ } \endqml - It is important to note that properties of JavaScript objects cannot - be bound to: + It is important to note that changes in regular properties of JavaScript + objects assigned to a var property will \bold{not} trigger updates of bindings + that access them. The example below will display "The car has 4 wheels" as + the change to the wheels property will not cause the reevaluation of the + binding assigned to the "text" property: \qml Item { - property var car: new vehicle(4) - property int wheelCount: car.wheels + property var car: new Object({wheels: 4}) - function vehicle(wheels) { - this.wheels = wheels; - this.talk = function() { print("I have " + this.wheels + " wheels!"); } + Text { + text: "The car has " + car.wheels + " wheels"; } Component.onCompleted: { - car.wheels = 6; // wheelCount will _not_ be updated + car.wheels = 6; } } \endqml -- 2.7.4