summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2011-04-05 06:55:18 (GMT)
committerBea Lam <bea.lam@nokia.com>2011-04-12 01:07:49 (GMT)
commitf2219ce983098fc14655d8f3bb8a7fee2c9abe4d (patch)
treef8efd2e3eab7ff4ee868985fa7cdeb3fad0f0f1e /doc
parent6ec7695eaa02c923b90d72e3918b9ab50da63e41 (diff)
downloadQt-f2219ce983098fc14655d8f3bb8a7fee2c9abe4d.zip
Qt-f2219ce983098fc14655d8f3bb8a7fee2c9abe4d.tar.gz
Qt-f2219ce983098fc14655d8f3bb8a7fee2c9abe4d.tar.bz2
Allow enum values to be used as signal parameters
The fix does not work for enums declared outside of the class that emits the signal, since in this case it is not possible to access the metaobject of the class that declared the enum. However the fix makes a special case for the Qt namespace to allow enums in this namespace to be used. Task-number: QTBUG-15983 Change-Id: I6f72255b07010311a20fe068bd97c7db7b294d9b Reviewed-by: Aaron Kennedy
Diffstat (limited to 'doc')
-rw-r--r--doc/src/declarative/qtbinding.qdoc19
-rw-r--r--doc/src/snippets/declarative/qtbinding/enums/standalone.qml15
2 files changed, 34 insertions, 0 deletions
diff --git a/doc/src/declarative/qtbinding.qdoc b/doc/src/declarative/qtbinding.qdoc
index 03290aa..4b380a4 100644
--- a/doc/src/declarative/qtbinding.qdoc
+++ b/doc/src/declarative/qtbinding.qdoc
@@ -365,6 +365,10 @@ instead to create the signal handler:
\o \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/MyItem.qml 0
\endtable
+C++ signals can use enum values as parameters provided that the enum is declared in the
+class that is emitting the signal, and that the enum is registered using Q_ENUMS.
+See \l {Using enumerations of a custom type} below for details.
+
\section2 Modifying properties
@@ -499,6 +503,21 @@ See the \l {Tutorial: Writing QML extensions with C++}{Writing QML extensions wi
the \l {Extending QML in C++} reference documentation for more information.
+\section2 Using enumeration values as signal parameters
+
+C++ signals may pass enumeration values as signal parameters to QML, providing that the enumeration
+and the signal are declared within the same class, or that the enumeration value is one of those declared
+in the \l {Qt}{Qt Namespace}.
+
+Additionally, if a C++ signal with an enum parameter should be connectable to a QML function using the
+\l {Connecting signals to methods and other signals}{connect()} function, the enum type must be
+registered using qRegisterMetaType().
+
+For QML signals, enum values may be used as signal parameters using the \c int type:
+
+\snippet doc/src/snippets/declarative/qtbinding/enums/standalone.qml 1
+
+
\section2 Automatic type conversion from strings
As a convenience, some basic types can be specified in QML using format strings to make it easier to
diff --git a/doc/src/snippets/declarative/qtbinding/enums/standalone.qml b/doc/src/snippets/declarative/qtbinding/enums/standalone.qml
index 5721870..74e2c9c 100644
--- a/doc/src/snippets/declarative/qtbinding/enums/standalone.qml
+++ b/doc/src/snippets/declarative/qtbinding/enums/standalone.qml
@@ -38,6 +38,9 @@
**
****************************************************************************/
import MyLibrary 1.0
+import QtQuick 1.0
+
+Item {
//![0]
ImageViewer {
@@ -47,3 +50,15 @@ ImageViewer {
}
}
//![0]
+
+//![1]
+ImageViewer {
+ signal someOtherSignal(int statusValue)
+
+ Component.onCompleted: {
+ someOtherSignal(ImageViewer.Loading)
+ }
+}
+//![1]
+
+}