aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/doc/src/qmlfunctions.qdoc
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2018-10-26 14:46:48 +0200
committerMitch Curtis <mitch.curtis@qt.io>2018-11-07 08:48:37 +0000
commit900786226404c915f3b2eb2840a1f3eb391db69b (patch)
treebe455483f5f7ced303200fde8404fe805fef4daf /src/qml/doc/src/qmlfunctions.qdoc
parentb1f07986c30978ed6636457e8d3f4a65c5db38a3 (diff)
Doc: improve qmlRegisterInterface() documentation
Change-Id: I5e8b63a287c65baf1eb53957cc5a9585176db284 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/doc/src/qmlfunctions.qdoc')
-rw-r--r--src/qml/doc/src/qmlfunctions.qdoc33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/qml/doc/src/qmlfunctions.qdoc b/src/qml/doc/src/qmlfunctions.qdoc
index 62c0f5d81b..969dd51433 100644
--- a/src/qml/doc/src/qmlfunctions.qdoc
+++ b/src/qml/doc/src/qmlfunctions.qdoc
@@ -356,13 +356,36 @@
*/
/*!
- \fn int qmlRegisterInterface(const char *typeName)
- \relates QQmlEngine
+ \fn int qmlRegisterInterface(const char *typeName)
+ \relates QQmlEngine
- This template function registers the C++ type in the QML system
- under the name \a typeName.
+ This template function registers the C++ type in the QML system
+ under the name \a typeName.
- Returns the QML type id.
+ Types registered as an interface with the engine should also
+ declare themselves as an interface with the
+ \l {The Meta-Object System}{meta object system}. For example:
+
+ \code
+ struct FooInterface
+ {
+ public:
+ virtual ~FooInterface();
+ virtual void doSomething() = 0;
+ };
+
+ Q_DECLARE_INTERFACE(FooInterface, "org.foo.FooInterface")
+ \endcode
+
+ When registered with the QML engine in this way, they can be used as
+ property types:
+
+ Q_PROPERTY(FooInterface *foo READ foo WRITE setFoo)
+
+ When you assign a \l QObject sub-class to this property, the QML engine does
+ the interface cast to \c FooInterface* automatically.
+
+ Returns the QML type id.
*/
/*!