diff options
Diffstat (limited to 'src/qml/doc/src/cppintegration/extending-tutorial.qdoc')
-rw-r--r-- | src/qml/doc/src/cppintegration/extending-tutorial.qdoc | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/qml/doc/src/cppintegration/extending-tutorial.qdoc b/src/qml/doc/src/cppintegration/extending-tutorial.qdoc index 3a9c5d1579..28c310e495 100644 --- a/src/qml/doc/src/cppintegration/extending-tutorial.qdoc +++ b/src/qml/doc/src/cppintegration/extending-tutorial.qdoc @@ -78,8 +78,8 @@ several custom QML types connected together through QML features like bindings a signals, and made available to the QML runtime through a plugin. To begin with, let's create a new QML type called "PieChart" that has two properties: a name -and a color. We will make it available in a \l {Modules}{module} called "Charts", with -a module version of 1.0. +and a color. We will make it available in an importable type namespace called "Charts", with +a version of 1.0. We want this \c PieChart type to be usable from QML like this: @@ -144,8 +144,8 @@ Here is the application \c main.cpp: \snippet examples/tutorials/extending/chapter1-basics/main.cpp 0 -This call to qmlRegisterType() registers the \c PieChart type as a type called "PieChart", in a module named "Charts", -with a module version of 1.0. +This call to qmlRegisterType() registers the \c PieChart type as a type called "PieChart", +in a type namespace called "Charts", with a version of 1.0. Lastly, we write a \c .pro project file that includes the files and the \c declarative library: @@ -327,7 +327,7 @@ item when its contents are drawn: Like the \c PieChart type, the \c PieSlice type has to be registered using qmlRegisterType() to be used from QML. As with \c PieChart, we'll add the -type to the "Charts" module, version 1.0: +type to the "Charts" type namespace, version 1.0: \snippet examples/tutorials/extending/chapter4-customPropertyTypes/main.cpp 0 \dots @@ -398,8 +398,8 @@ Currently the \c PieChart and \c PieSlice types are used by \c app.qml, which is displayed using a QQuickView in a C++ application. An alternative way to use our QML extension is to create a plugin library to make it available to the QML engine. This would allow the \c PieChart and \c PieSlice types to be -imported as part of a module by any QML application, instead of restricting these -types to be only used by the one application. +registered into a type namespace which could be imported by any QML application, +instead of restricting these types to be only used by the one application. The setps for creating a plugin are described in \l {Creating C++ Plugins for QML}. To start with, we create a plugin class named \c ChartsPlugin. It subclasses QQmlExtensionPlugin @@ -418,23 +418,23 @@ and specifies with DESTDIR that library files should be built into a "lib" subdi \quotefile examples/tutorials/extending/chapter6-plugins/chapter6-plugins.pro -Finally, we add a \l{Adding Module Metadata with a qmldir file}{qmldir} file that is -automatically parsed by the QML engine. In this file, we specify that a plugin named +Finally, we add a \l{qtqml-modules-qmldir.html}{qmldir} file that is +parsed by the QML engine. In this file, we specify that a plugin named "chapter6-plugin" (the name of the example project) can be found in the "lib" subdirectory: \quotefile examples/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir Now we have a plugin, and instead of having a main.cpp and an executable, we can build -the project and then load the QML file using the \l{Prototyping with qmlscene}{qmlscene tool}: +the project and then load the QML file using the \l{Prototyping with qmlscene}{qmlscene tool}, +setting the import path to the current directory so that it finds the \c qmldir file: \code - qmlscene app.qml + qmlscene -I . app.qml \endcode -Notice the "import Charts 1.0" statement has disappeared from \c app.qml. This is -because the \c qmldir file is in the same directory as \c app.qml: this is equivalent to -having PieChart.qml and PieSlice.qml files inside the project directory, which could both -be used by \c app.qml without import statements. +The module "Charts" will be loaded by the QML engine, and the types provided by that +module will be available for use in any QML document which imports it. + */ |