aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/doc
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/doc')
-rw-r--r--src/qml/doc/src/qmlfunctions.qdoc33
-rw-r--r--src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc6
2 files changed, 33 insertions, 6 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.
*/
/*!
diff --git a/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc b/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc
index 7c1d65b095..01e81e7c19 100644
--- a/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc
+++ b/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc
@@ -23,7 +23,7 @@ plugins. Library plugins should limit themselves to registering types, as
any manipulation of the engine's root context may cause conflicts or other
issues in the library user's code.
-\section1 Plugin Example
+\section1 TimeExample QML extension plugin
Suppose there is a new \c TimeModel C++ class that should be made available
as a new QML type. It provides the current time through \c hour and \c minute
@@ -47,6 +47,8 @@ imported correctly by any QML components that use this plugin. The
\l{Defining QML Types from C++} article has more information about registering C++
types into the runtime.
+\section1 Project settings for the plugin
+
Additionally, the project file (\c .pro) defines the project as a plugin library,
specifies it should be built into the \c imports/TimeExample directory, and registers
the plugin target name and various other details:
@@ -61,6 +63,8 @@ TARGET = qmlqtimeexampleplugin
SOURCES += qexampleqmlplugin.cpp
\endcode
+\section1 Plugin definition in the qmldir
+
Finally, a \l{Module Definition qmldir Files}{qmldir file} is required
in the \c imports/TimeExample directory to describe the plugin and the types that it
exports. The plugin includes a \c Clock.qml file along with the \c qmlqtimeexampleplugin