aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2012-07-27 17:03:44 +1000
committerQt by Nokia <qt-info@nokia.com>2012-07-27 10:45:41 +0200
commit3344e950d85c130e8be45ec78fa0b25e6f8f7f3a (patch)
treed37284a58d8dc3fa6fa3f1a2925f0864e5a89637
parent29093aedee6969a5ea5c3d19d19fb40dbdd811e7 (diff)
Clarify use of enumeration type from QML code
Change-Id: I5aea6ec8c4daada284bc7881bbc3379e5ab61b94 Reviewed-by: Chris Adams <christopher.adams@nokia.com>
-rw-r--r--src/qml/doc/src/typesystem/basictypes.qdoc34
1 files 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 {<Type>.<value>}. 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}
*/