From bc49400b7df51312e918097de429826484fa5c61 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 4 Jan 2018 13:13:43 +0100 Subject: Doc: state that property aliases do not work with grouped properties It seems to have been the case since the beginning (a bug report linked to from the report referenced here is from 2010), so we should document it until the opposite becomes true. Task-number: QTBUG-65011 Change-Id: I9de0836e024df35968c85c7136cec04b6b4a741c Reviewed-by: Simon Hausmann --- .../qmllanguageref/syntax/objectattributes.qdoc | 39 ++++++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) (limited to 'src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc') diff --git a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc index d789c67fde..568ad930f2 100644 --- a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc +++ b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc @@ -448,13 +448,38 @@ right-hand-side of the property declaration must be a valid alias reference: [default] property alias : \endcode -Unlike an ordinary property, an alias can only refer to an object, or the -property of an object, that is within the scope of the \l{QML Object Types} -{type} within which the alias is declared. It cannot contain arbitrary -JavaScript expressions and it cannot refer to objects declared outside of -the scope of its type. Also note the \e {alias reference} is not optional, -unlike the optional default value for an ordinary property; the alias reference -must be provided when the alias is first declared. +Unlike an ordinary property, an alias has the following restrictions: + +\list +\li It can only refer to an object, or the + property of an object, that is within the scope of the \l{QML Object Types} + {type} within which the alias is declared. +\li It cannot contain arbitrary + JavaScript expressions +\li It cannot refer to objects declared outside of + the scope of its type. +\li The \e {alias reference} is not optional, + unlike the optional default value for an ordinary property; the alias reference + must be provided when the alias is first declared. +\li It cannot refer to grouped properties; the following code will not work: + \code + property alias color: rectangle.border.color + + Rectangle { + id: rectangle + } + \endcode + + However, aliases to \l {QML Basic Types}{value type} properties do work: + \code + property alias rectX: object.rectProperty.x + + Item { + id: object + property rect rectProperty + } + \endcode +\endlist For example, below is a \c Button type with a \c buttonText aliased property which is connected to the \c text object of the \l Text child: -- cgit v1.2.3