From 88bd1a9a1f94d02ff7e61101574db75feadade9c Mon Sep 17 00:00:00 2001 From: Jaishree Vyas Date: Thu, 10 Mar 2022 16:05:10 +0100 Subject: 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 Reviewed-by: Qt CI Bot --- src/qml/doc/snippets/qml/CMakeLists.txt | 11 +++++++++++ .../doc/snippets/qml/MajorProject-CMakeLists.txt | 23 ++++++++++++++++++++++ src/qml/doc/snippets/qml/myProject-CMakeLists.txt | 13 ++++++++++++ src/qml/doc/snippets/qml/myimageprovider.txt | 15 ++++++++++++++ src/qml/doc/snippets/qml/plugin.cpp.txt | 14 +++++++++++++ 5 files changed, 76 insertions(+) create mode 100644 src/qml/doc/snippets/qml/CMakeLists.txt create mode 100644 src/qml/doc/snippets/qml/MajorProject-CMakeLists.txt create mode 100644 src/qml/doc/snippets/qml/myProject-CMakeLists.txt create mode 100644 src/qml/doc/snippets/qml/myimageprovider.txt create mode 100644 src/qml/doc/snippets/qml/plugin.cpp.txt (limited to 'src/qml/doc/snippets') 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 +#include + +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); + } +}; -- cgit v1.2.3