Document readonly property syntax
authorBea Lam <bea.lam@nokia.com>
Mon, 30 Jul 2012 08:01:01 +0000 (18:01 +1000)
committerQt by Nokia <qt-info@nokia.com>
Wed, 1 Aug 2012 10:00:29 +0000 (12:00 +0200)
Reviewed-by: Chris Adams <christopher.adams@nokia.com>

Change-Id: Ibaf68b39526824098aa67f7d1fdce6d12e3b3111
Reviewed-by: Chris Adams <christopher.adams@nokia.com>

src/qml/doc/src/syntax/objectattributes.qdoc

index f199b6a..741b7cb 100644 (file)
@@ -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