From 3344e950d85c130e8be45ec78fa0b25e6f8f7f3a Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 27 Jul 2012 17:03:44 +1000 Subject: Clarify use of enumeration type from QML code Change-Id: I5aea6ec8c4daada284bc7881bbc3379e5ab61b94 Reviewed-by: Chris Adams --- src/qml/doc/src/typesystem/basictypes.qdoc | 34 +++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/qml/doc/src/typesystem/basictypes.qdoc b/src/qml/doc/src/typesystem/basictypes.qdoc index 98f330c17b..176a56a3cf 100644 --- a/src/qml/doc/src/typesystem/basictypes.qdoc +++ b/src/qml/doc/src/typesystem/basictypes.qdoc @@ -1014,9 +1014,9 @@ property is only invoked when the property is reassigned to a different object v /*! \qmlbasictype enumeration \ingroup qmlbasictypes - \brief a set of named values. + \brief a named enumeration value. - The \c enumeration type refers to a set of named values. + The \c enumeration type refers to a named enumeration value. Each named value can be referred to as \c {.}. For example, the \l Text type has an \c AlignRight enumeration value: @@ -1029,13 +1029,41 @@ property is only invoked when the property is reassigned to a different object v specified as a string, e.g. "AlignRight". This form is not recommended for new code.) - When integrating with C++, note that any enumeration value + When integrating with C++, note that any \c enum value \l{qtqml-cppintegration-data.html}{passed into QML from C++} is automatically converted into an \c enumeration value, and vice-versa. This basic type is provided by the QML language. Some enumeration values are provided by the QtQuick import. + \section1 Using the enumeration type in QML + + The \c enumeration type is a representation of a C++ \c enum type. It is + not possible to refer to the \c enumeration type in QML itself; instead, the + \l int or \l var types can be used when referring to \c enumeration values + from QML code. + + For example: + + \qml + import QtQuick 2.0 + + Item { + // refer to Text.AlignRight using an int type + property int enumValue: textItem.horizontalAlignment + + signal valueEmitted(int someValue) + + Text { + id: textItem + horizontalAlignment: Text.AlignRight + } + + // emit valueEmitted() signal, which expects an int, with Text.AlignRight + Component.onCompleted: valueEmitted(Text.AlignRight) + } + \endqml + \sa {QML Basic Types} */ -- cgit v1.2.3