Fix documentation for property var
authorChris Adams <christopher.adams@nokia.com>
Tue, 1 Nov 2011 06:54:47 +0000 (16:54 +1000)
committerQt by Nokia <qt-info@nokia.com>
Fri, 4 Nov 2011 04:29:17 +0000 (05:29 +0100)
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 <martin.jones@nokia.com>
doc/src/declarative/basictypes.qdoc

index 1bc1373..5e4ce9a 100644 (file)
     }
     \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