summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlmoduleplugin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml/qmlmoduleplugin.cpp')
-rw-r--r--src/declarative/qml/qmlmoduleplugin.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/declarative/qml/qmlmoduleplugin.cpp b/src/declarative/qml/qmlmoduleplugin.cpp
index 3346ec7..2f2cb25 100644
--- a/src/declarative/qml/qmlmoduleplugin.cpp
+++ b/src/declarative/qml/qmlmoduleplugin.cpp
@@ -59,11 +59,12 @@ QT_BEGIN_NAMESPACE
exporting the class with the Q_EXPORT_PLUGIN2() macro. See \l{How
to Create Qt Plugins} for details.
- The plugin should register QML types with QML_DEFINE_TYPE.
-
The strings returned by keys() should be the list of URIs of modules
that the plugin registers.
+ The plugin should register QML types with qmlRegisterType() when the
+ defineModule() method is called.
+
\sa examples/declarative/plugins
*/
@@ -86,4 +87,25 @@ QmlModulePlugin::~QmlModulePlugin()
{
}
+/*!
+ \fn void QmlModulePlugin::defineModule(const QString& uri)
+
+ Subclasses must override this function to register types
+ of the module \a uri, which will be one of the strings returned by keys().
+
+ The plugin registers QML types with qmlRegisterType():
+
+ \code
+ qmlRegisterType<MyClass>("com.nokia.MyModule", 1, 0, "MyType", "MyClass");
+ \endcode
+*/
+
+void QmlModulePlugin::defineModuleOnce(const QString& uri)
+{
+ if (!defined.contains(uri)) {
+ defined += uri;
+ defineModule(uri);
+ }
+}
+
QT_END_NAMESPACE