diff options
author | Olivier De Cannière <olivier.decanniere@qt.io> | 2023-04-28 11:08:02 +0200 |
---|---|---|
committer | Olivier De Cannière <olivier.decanniere@qt.io> | 2023-05-12 15:06:42 +0200 |
commit | d88b52b541a0482b69639dbea8976287db9ca52b (patch) | |
tree | 459b4e3e373a23a7e0578aece4dc4b5cccaf9ba4 /src/qml | |
parent | 13fc038d8d4baa9e199fbd5a7e4c08650a88172e (diff) | |
download | qtdeclarative-d88b52b541a0482b69639dbea8976287db9ca52b.tar.gz |
Examples: Move Qml plugin example to manual tests
Outdated documention has been removed.
Task-number: QTBUG-111036
Change-Id: I8db138ff71615a6ed6ac4cebdb365c27252fa5ee
Pick-to: 6.5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc b/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc index fca702a278..771d520f8a 100644 --- a/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc +++ b/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc @@ -62,85 +62,3 @@ that's part of the same binary as the registration: volatile auto registration = &qml_register_types_my_module; Q_UNUSED(registration); \endcode - -\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 -properties. It declares a QML type called \c Time via \l QML_NAMED_ELEMENT(). - -\snippet qmlextensionplugins/timemodel.h 0 -\dots - -To make this type available, create a plugin class named \c QExampleQmlPlugin, -which is a subclass of \l QQmlEngineExtensionPlugin. It uses the -Q_PLUGIN_METADATA() macro in the class definition to register the plugin with -the Qt meta object system using a unique identifier for the plugin. - -\snippet qmlextensionplugins/plugin.cpp plugin - -\section1 Build Settings for the Plugin - -The build file defines the project as a plugin library, specifies it should be -built into the \c imports/TimeExample directory, and registers the plugin -target name. - -\section2 Using CMake: - -\snippet qmlextensionplugins/CMakeLists.txt 0 - -\snippet qmlextensionplugins/CMakeLists.txt 1 - -\section2 Using qmake: - -\code -TEMPLATE = lib -CONFIG += qt plugin qmltypes -QT += qml - -QML_IMPORT_NAME = TimeExample -QML_IMPORT_MAJOR_VERSION = 1 - -DESTDIR = imports/$$QML_IMPORT_NAME -TARGET = qmlqtimeexampleplugin - -SOURCES += qexampleqmlplugin.cpp -\endcode - -This registers the \c TimeModel class, with the import \c{TimeExample 1.0}, as -a QML type called \c Time. The \l{Defining QML Types from C++} article has more -information about registering C++ types for usage in QML. - -\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 that is built by the project. - -CMake will, by default, automatically generate this file. For more -information, see \l {Auto-generating qmldir and typeinfo files}. - -When using qmake, specify the following in the \c qmldir file: - -\quotefile qmlextensionplugins/imports/TimeExample/qmldir - -To make things easier for this example, the TimeExample source directory is in -\c{imports/TimeExample}, and we build -\l{Source, Build, and Install Directories}{in-source}. However, the structure -of the source directory is not important, as the \c qmldir file can specify -paths to installed QML files. - -What is important is the name of the directory that the qmldir is installed -into. When the user imports our module, the QML engine uses the -\l{Contents of a Module Definition qmldir File}{module identifier} -(\c TimeExample) to find the plugin, so the directory in which it is -installed must match the module identifier. - -Once the project is built and installed, the new \c Time component is -accessible by any QML component that imports the \c TimeExample -module. - -\snippet qmlextensionplugins/plugins.qml 0 - -The full source code is available in the \l {qmlextensionplugins}{plugins example}. |