From 59b021221595e511ea5819ed4b503f43bd1bcc5f Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Wed, 24 Mar 2021 09:53:01 +0100 Subject: Beautify bindable properties documentation Some minor formatting changes Change-Id: I336a442d01cb048397b2a65977cfb96bb7179752 Reviewed-by: Edward Welbourne Reviewed-by: Paul Wicking --- .../doc/src/objectmodel/bindableproperties.qdoc | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'src/corelib/doc/src/objectmodel/bindableproperties.qdoc') diff --git a/src/corelib/doc/src/objectmodel/bindableproperties.qdoc b/src/corelib/doc/src/objectmodel/bindableproperties.qdoc index c84928d67a..b0241a3d4f 100644 --- a/src/corelib/doc/src/objectmodel/bindableproperties.qdoc +++ b/src/corelib/doc/src/objectmodel/bindableproperties.qdoc @@ -127,23 +127,24 @@ Bindable properties must not be used as variables in algorithms. Each value written would be communicated to dependent properties. - For example, in the following code, other properties dependent on myProperty would be - first informed about the change to 42, then about the change to maxvalue. + For example, in the following code, other properties that depend on + \b myProperty would be first informed about the change to \b 42, then about + the change to \b maxValue. \badcode myProperty = somecomputation(); // returning, say, 42 - if (myProperty.value() > maxvalue) - myProperty = maxvalue; + if (myProperty.value() > maxValue) + myProperty = maxValue; \endcode Instead, perform the computation in a separate variable. Correct usage is shown in the following example. \code - int newvalue = somecomputation(); - if (newvalue > maxvalue) - newvalue = maxvalue; - myProperty = newvalue; // only write to the property once + int newValue = someComputation(); + if (newValue > maxValue) + newValue = maxValue; + myProperty = newValue; // only write to the property once \endcode \section2 Writing Bindable Properties in Transitional States @@ -153,15 +154,15 @@ not be written in transient states, when class invariants are not met. For example, in a class representing a circle which holds two members - "radius" and "area" consistent, a setter might look like this (where radius + \b radius and \b area consistent, a setter might look like this (where radius is a bindable property): \badcode - void setRadius(double newvalue) + void setRadius(double newValue) { - radius = newvalue; // this might trigger change handlers - area = M_PI*radius*radius; - emit radiusChanged(); + radius = newValue; // this might trigger change handlers + area = M_PI * radius * radius; + emit radiusChanged(); } \endcode -- cgit v1.2.3