summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorAndreas Buhr <andreas.buhr@qt.io>2021-03-24 09:53:01 +0100
committerAndreas Buhr <andreas.buhr@qt.io>2021-03-26 08:42:07 +0100
commit59b021221595e511ea5819ed4b503f43bd1bcc5f (patch)
tree976725ad56ee591c0f3571d38a7cd16b1153c8a6 /src/corelib
parent3e65d0408b830518ca2f18c8d0d583cbb665d1f3 (diff)
Beautify bindable properties documentation
Some minor formatting changes Change-Id: I336a442d01cb048397b2a65977cfb96bb7179752 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/doc/src/objectmodel/bindableproperties.qdoc27
1 files changed, 14 insertions, 13 deletions
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