diff options
Diffstat (limited to 'doc')
-rw-r--r-- | doc/src/declarative/qtbinding.qdoc | 19 | ||||
-rw-r--r-- | doc/src/snippets/declarative/qtbinding/enums/standalone.qml | 15 |
2 files changed, 34 insertions, 0 deletions
diff --git a/doc/src/declarative/qtbinding.qdoc b/doc/src/declarative/qtbinding.qdoc index d11825e..3659caa 100644 --- a/doc/src/declarative/qtbinding.qdoc +++ b/doc/src/declarative/qtbinding.qdoc @@ -368,6 +368,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 @@ -503,6 +507,21 @@ the \l {Extending QML Functionalities using 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] + +} |