aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/doc/snippets
diff options
context:
space:
mode:
authorJaishree Vyas <jaishree.vyas@qt.io>2022-03-10 16:05:10 +0100
committerJaishree Vyas <Jaishree.Vyas@qt.io>2022-03-31 23:38:31 +0200
commit88bd1a9a1f94d02ff7e61101574db75feadade9c (patch)
tree2f1bd1044dd6da27f7dc858c59c4361de33d7656 /src/qml/doc/snippets
parent396d8b0d1759281f8de406e0c4b0b23a8999449c (diff)
Doc: Write QML Modules
Based on a Blog post Task-number: QTBUG-100450 Pick-to: 6.2 6.3 Change-Id: I42ade9906e8ba5ebeb1e78cfe3343ac9d89dcada Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/qml/doc/snippets')
-rw-r--r--src/qml/doc/snippets/qml/CMakeLists.txt11
-rw-r--r--src/qml/doc/snippets/qml/MajorProject-CMakeLists.txt23
-rw-r--r--src/qml/doc/snippets/qml/myProject-CMakeLists.txt13
-rw-r--r--src/qml/doc/snippets/qml/myimageprovider.txt15
-rw-r--r--src/qml/doc/snippets/qml/plugin.cpp.txt14
5 files changed, 76 insertions, 0 deletions
diff --git a/src/qml/doc/snippets/qml/CMakeLists.txt b/src/qml/doc/snippets/qml/CMakeLists.txt
new file mode 100644
index 0000000000..24e775341f
--- /dev/null
+++ b/src/qml/doc/snippets/qml/CMakeLists.txt
@@ -0,0 +1,11 @@
+qt_add_library(extra_module STATIC)
+qt_add_qml_module(extra_module
+ URI "ExtraModule"
+ VERSION 1.0
+ QML_FILES
+ Extra.qml
+ SOURCES
+ extrathing.cpp extrathing.h
+)
+
+add_subdirectory(ExtraModule)
diff --git a/src/qml/doc/snippets/qml/MajorProject-CMakeLists.txt b/src/qml/doc/snippets/qml/MajorProject-CMakeLists.txt
new file mode 100644
index 0000000000..3e5cbd4565
--- /dev/null
+++ b/src/qml/doc/snippets/qml/MajorProject-CMakeLists.txt
@@ -0,0 +1,23 @@
+
+set_source_files_properties(Thing.qml
+ PROPERTIES
+ QT_QML_SOURCE_VERSIONS "1.4;2.0;3.0"
+)
+
+set_source_files_properties(OtherThing.qml
+ PROPERTIES
+ QT_QML_SOURCE_VERSIONS "2.2;3.0"
+)
+
+qt_add_qml_module(my_module
+ URI MyModule
+ VERSION 3.2
+ PAST_MAJOR_VERSIONS
+ 1 2
+ QML_FILES
+ Thing.qml
+ OtherThing.qml
+ OneMoreThing.qml
+ SOURCES
+ everything.cpp everything.h
+)
diff --git a/src/qml/doc/snippets/qml/myProject-CMakeLists.txt b/src/qml/doc/snippets/qml/myProject-CMakeLists.txt
new file mode 100644
index 0000000000..49c63a1513
--- /dev/null
+++ b/src/qml/doc/snippets/qml/myProject-CMakeLists.txt
@@ -0,0 +1,13 @@
+qt_add_executable(main_program main.cpp)
+
+qt_add_qml_module(main_program
+ VERSION 1.0
+ URI myProject
+ QML_FILES
+ main.qml
+ SOURCES
+ onething.cpp onething.h
+
+)
+
+target_link_libraries(main_program PRIVATE extra_moduleplugin)
diff --git a/src/qml/doc/snippets/qml/myimageprovider.txt b/src/qml/doc/snippets/qml/myimageprovider.txt
new file mode 100644
index 0000000000..4605734398
--- /dev/null
+++ b/src/qml/doc/snippets/qml/myimageprovider.txt
@@ -0,0 +1,15 @@
+qt_add_qml_module(imageproviderplugin
+ VERSION 1.0
+ URI "ImageProvider"
+ PLUGIN_TARGET imageproviderplugin
+ NO_PLUGIN_OPTIONAL
+ NO_GENERATE_PLUGIN_SOURCE
+ CLASS_NAME ImageProviderExtensionPlugin
+ QML_FILES
+ AAA.qml
+ BBB.qml
+ SOURCES
+ moretypes.cpp moretypes.h
+ myimageprovider.cpp myimageprovider.h
+ plugin.cpp
+)
diff --git a/src/qml/doc/snippets/qml/plugin.cpp.txt b/src/qml/doc/snippets/qml/plugin.cpp.txt
new file mode 100644
index 0000000000..02d1112a4a
--- /dev/null
+++ b/src/qml/doc/snippets/qml/plugin.cpp.txt
@@ -0,0 +1,14 @@
+#include <myimageprovider.h>
+#include <QtQml/qqmlextensionplugin.h>
+
+class ImageProviderExtensionPlugin : public QQmlEngineExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid)
+public:
+ void initializeEngine(QQmlEngine *engine, const char *uri) final
+ {
+ Q_UNUSED(uri);
+ engine->addImageProvider("myimg", new MyImageProvider);
+ }
+};