aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2012-07-30 18:01:01 +1000
committerQt by Nokia <qt-info@nokia.com>2012-08-01 12:00:29 +0200
commit49b3865f99343d3b91392b2560e217f6f48438ea (patch)
treea39c0664f7d0fecf5df21ab59d4925f513061f15 /src/qml
parent1eba1f23a5c0a3ab7941bf508b03b7230646befd (diff)
Document readonly property syntax
Reviewed-by: Chris Adams <christopher.adams@nokia.com> Change-Id: Ibaf68b39526824098aa67f7d1fdce6d12e3b3111 Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/doc/src/syntax/objectattributes.qdoc29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/qml/doc/src/syntax/objectattributes.qdoc b/src/qml/doc/src/syntax/objectattributes.qdoc
index f199b6abba..741b7cbb91 100644
--- a/src/qml/doc/src/syntax/objectattributes.qdoc
+++ b/src/qml/doc/src/syntax/objectattributes.qdoc
@@ -515,7 +515,7 @@ aliasing an aliasing property will also result in an error.
\snippet qml/properties.qml alias complete
-When importing a \l{QML Object Types}QML object type} with a property alias in
+When importing a \l{QML Object Types}{QML object type} with a property alias in
the root object, however, the property appear as a regular Qt property and
consequently can be used in alias references.
@@ -587,6 +587,33 @@ default property to automatically reassign children of the TabWidget as
children of an inner ListView.
+\section3 Read-Only Properties
+
+An object declaration may define a read-only property using the \c readonly
+keyword, with the following syntax:
+
+\code
+ readonly property <propertyType> <propertyName> : <initialValue>
+\endcode
+
+Read-only properties must be assigned a value on initialization. After a
+read-only property is initialized, it no longer possible to give it a value,
+whether from imperative code or otherwise.
+
+For example, the code in the \c Component.onCompleted block below is invalid:
+
+\qml
+Item {
+ readonly property int someNumber: 10
+
+ Component.onCompleted: someNumber = 20 // doesn't work, causes an error
+}
+\endqml
+
+\note A read-only property cannot also be a \l{Default Properties}{default} or
+\l {Property Aliases}{alias} property.
+
+
\section2 Signal Attributes
A signal is a notification from an object that some event has occurred: for