aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qml
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@qt.io>2021-08-23 16:29:18 +1000
committerCraig Scott <craig.scott@qt.io>2021-08-25 10:44:35 +1000
commit58127aa35945dc76bd71b69b25d141025267f4c8 (patch)
tree0598b09ef3a806adefc2a789abb7766405a3a180 /examples/qml
parent938aebaa14c99e1f05d3a13530e924067cbe07a3 (diff)
Update qml examples for improved target path handling
Some examples were still using the old "add as ordinary resources" approach for QML modules, others needed adjustment to the subdirectory structure to better reflect the URI structure of the QML modules involved. Task-number: QTBUG-95144 Change-Id: Ie3399410cf6df491eb1e7b4a589ca26c577d82a0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 9e1d2a0eb15487f8f2acb4d91b281568897fb4e1)
Diffstat (limited to 'examples/qml')
-rw-r--r--examples/qml/.prev_CMakeLists.txt12
-rw-r--r--examples/qml/networkaccessmanagerfactory/CMakeLists.txt16
-rw-r--r--examples/qml/qmlextensionplugins/CMakeLists.txt30
-rw-r--r--examples/qml/referenceexamples/adding/CMakeLists.txt23
-rw-r--r--examples/qml/referenceexamples/attached/CMakeLists.txt23
-rw-r--r--examples/qml/referenceexamples/binding/CMakeLists.txt23
-rw-r--r--examples/qml/referenceexamples/coercion/CMakeLists.txt23
-rw-r--r--examples/qml/referenceexamples/default/CMakeLists.txt23
-rw-r--r--examples/qml/referenceexamples/extended/CMakeLists.txt23
-rw-r--r--examples/qml/referenceexamples/grouped/CMakeLists.txt23
-rw-r--r--examples/qml/referenceexamples/methods/CMakeLists.txt23
-rw-r--r--examples/qml/referenceexamples/properties/CMakeLists.txt23
-rw-r--r--examples/qml/referenceexamples/signal/CMakeLists.txt23
-rw-r--r--examples/qml/referenceexamples/valuesource/CMakeLists.txt23
-rw-r--r--examples/qml/tutorials/extending-qml/.prev_CMakeLists.txt8
-rw-r--r--examples/qml/tutorials/extending-qml/chapter1-basics/CMakeLists.txt23
-rw-r--r--examples/qml/tutorials/extending-qml/chapter2-methods/CMakeLists.txt23
-rw-r--r--examples/qml/tutorials/extending-qml/chapter3-bindings/CMakeLists.txt23
-rw-r--r--examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/CMakeLists.txt23
-rw-r--r--examples/qml/tutorials/extending-qml/chapter5-listproperties/CMakeLists.txt23
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/.prev_CMakeLists.txt51
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/CMakeLists.txt19
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/CMakeLists.txt (renamed from examples/qml/tutorials/extending-qml/chapter6-plugins/import/CMakeLists.txt)0
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/Charts.pro (renamed from examples/qml/tutorials/extending-qml/chapter6-plugins/import/import.pro)4
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/chartsplugin.h (renamed from examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.h)0
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/piechart.cpp (renamed from examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.cpp)0
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/piechart.h (renamed from examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.h)0
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/pieslice.cpp (renamed from examples/qml/tutorials/extending-qml/chapter6-plugins/import/pieslice.cpp)0
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/pieslice.h (renamed from examples/qml/tutorials/extending-qml/chapter6-plugins/import/pieslice.h)0
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/qmldir (renamed from examples/qml/tutorials/extending-qml/chapter6-plugins/import/qmldir)0
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/chapter6-plugins.pro2
-rw-r--r--examples/qml/xmlhttprequest/CMakeLists.txt27
32 files changed, 121 insertions, 416 deletions
diff --git a/examples/qml/.prev_CMakeLists.txt b/examples/qml/.prev_CMakeLists.txt
deleted file mode 100644
index 0ec4c9b39d..0000000000
--- a/examples/qml/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-# Generated from qml.pro.
-
-add_subdirectory(referenceexamples)
-add_subdirectory(tutorials)
-add_subdirectory(shell)
-if(TARGET Qt::Quick)
- add_subdirectory(qmlextensionplugins)
- add_subdirectory(xmlhttprequest)
-endif()
-if(QT_FEATURE_qml_network AND TARGET Qt::Quick)
- add_subdirectory(networkaccessmanagerfactory)
-endif()
diff --git a/examples/qml/networkaccessmanagerfactory/CMakeLists.txt b/examples/qml/networkaccessmanagerfactory/CMakeLists.txt
index 90afa4b5a1..fd4444a99b 100644
--- a/examples/qml/networkaccessmanagerfactory/CMakeLists.txt
+++ b/examples/qml/networkaccessmanagerfactory/CMakeLists.txt
@@ -36,17 +36,11 @@ target_link_libraries(networkaccessmanagerfactory PUBLIC
Qt::Quick
)
-
-# Resources:
-set(networkaccessmanagerfactory_resource_files
- "view.qml"
-)
-
-qt6_add_resources(networkaccessmanagerfactory "networkaccessmanagerfactory"
- PREFIX
- "/"
- FILES
- ${networkaccessmanagerfactory_resource_files}
+qt_add_qml_module(networkaccessmanagerfactory
+ URI Example
+ VERSION 1.0
+ QML_FILES view.qml
+ NO_RESOURCE_TARGET_PATH
)
install(TARGETS networkaccessmanagerfactory
diff --git a/examples/qml/qmlextensionplugins/CMakeLists.txt b/examples/qml/qmlextensionplugins/CMakeLists.txt
index 62a92e6033..8156f23eb1 100644
--- a/examples/qml/qmlextensionplugins/CMakeLists.txt
+++ b/examples/qml/qmlextensionplugins/CMakeLists.txt
@@ -14,20 +14,32 @@ if(NOT DEFINED INSTALL_EXAMPLESDIR)
endif()
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qml/qmlextensionplugins/imports/TimeExample")
-set(QT_QML_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/examples/qml/qmlextensionplugins/imports)
find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Qml)
-set_source_files_properties(imports/TimeExample/Clock.qml PROPERTIES
- QT_RESOURCE_ALIAS Clock.qml
+set(qml_files
+ imports/TimeExample/Clock.qml
)
+set(images
+ imports/TimeExample/center.png
+ imports/TimeExample/clock.png
+ imports/TimeExample/hour.png
+ imports/TimeExample/minute.png
+)
+foreach(file IN LISTS qml_files images)
+ get_filename_component(filename ${file} NAME)
+ set_source_files_properties(${file} PROPERTIES QT_RESOURCE_ALIAS ${filename})
+endforeach()
+
qt6_add_qml_module(qmlqtimeexample
+ OUTPUT_DIRECTORY TimeExample
VERSION 1.0
URI "TimeExample"
SOURCES timemodel.cpp timemodel.h
- QML_FILES imports/TimeExample/Clock.qml
+ QML_FILES ${qml_files}
+ RESOURCES ${images}
)
set_target_properties(qmlqtimeexample PROPERTIES
WIN32_EXECUTABLE TRUE
@@ -39,16 +51,6 @@ target_link_libraries(qmlqtimeexample PUBLIC
Qt::Qml
)
-qt6_add_resources(qmlqtimeexample example_images
- PREFIX "/TimeExample"
- BASE imports/TimeExample
- FILES
- imports/TimeExample/center.png
- imports/TimeExample/clock.png
- imports/TimeExample/hour.png
- imports/TimeExample/minute.png
-)
-
install(TARGETS qmlqtimeexample
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/qml/referenceexamples/adding/CMakeLists.txt b/examples/qml/referenceexamples/adding/CMakeLists.txt
index b90a7f6c36..b86d90a4c3 100644
--- a/examples/qml/referenceexamples/adding/CMakeLists.txt
+++ b/examples/qml/referenceexamples/adding/CMakeLists.txt
@@ -31,17 +31,11 @@ target_link_libraries(adding PUBLIC
Qt::Qml
)
-
-# Resources:
-set(adding_resource_files
- "example.qml"
-)
-
-qt6_add_resources(adding "adding"
- PREFIX
- "/"
- FILES
- ${adding_resource_files}
+qt_add_qml_module(adding
+ URI People
+ VERSION 1.0
+ QML_FILES example.qml
+ NO_RESOURCE_TARGET_PATH
)
install(TARGETS adding
@@ -49,10 +43,3 @@ install(TARGETS adding
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
-
-set_target_properties(adding PROPERTIES
- QT_QML_MODULE_VERSION 1.0
- QT_QML_MODULE_URI People
-)
-
-qt6_qml_type_registration(adding)
diff --git a/examples/qml/referenceexamples/attached/CMakeLists.txt b/examples/qml/referenceexamples/attached/CMakeLists.txt
index 684db88a95..4d49cc5663 100644
--- a/examples/qml/referenceexamples/attached/CMakeLists.txt
+++ b/examples/qml/referenceexamples/attached/CMakeLists.txt
@@ -34,17 +34,11 @@ target_link_libraries(attached PUBLIC
Qt::Qml
)
-
-# Resources:
-set(attached_resource_files
- "example.qml"
-)
-
-qt6_add_resources(attached "attached"
- PREFIX
- "/"
- FILES
- ${attached_resource_files}
+qt_add_qml_module(attached
+ URI People
+ VERSION 1.0
+ QML_FILES example.qml
+ NO_RESOURCE_TARGET_PATH
)
install(TARGETS attached
@@ -52,10 +46,3 @@ install(TARGETS attached
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
-
-set_target_properties(attached PROPERTIES
- QT_QML_MODULE_VERSION 1.0
- QT_QML_MODULE_URI People
-)
-
-qt6_qml_type_registration(attached)
diff --git a/examples/qml/referenceexamples/binding/CMakeLists.txt b/examples/qml/referenceexamples/binding/CMakeLists.txt
index fc733922bb..2a2d6575c0 100644
--- a/examples/qml/referenceexamples/binding/CMakeLists.txt
+++ b/examples/qml/referenceexamples/binding/CMakeLists.txt
@@ -35,17 +35,11 @@ target_link_libraries(binding PUBLIC
Qt::Qml
)
-
-# Resources:
-set(binding_resource_files
- "example.qml"
-)
-
-qt6_add_resources(binding "binding"
- PREFIX
- "/"
- FILES
- ${binding_resource_files}
+qt_add_qml_module(binding
+ URI People
+ VERSION 1.0
+ QML_FILES example.qml
+ NO_RESOURCE_TARGET_PATH
)
install(TARGETS binding
@@ -53,10 +47,3 @@ install(TARGETS binding
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
-
-set_target_properties(binding PROPERTIES
- QT_QML_MODULE_VERSION 1.0
- QT_QML_MODULE_URI People
-)
-
-qt6_qml_type_registration(binding)
diff --git a/examples/qml/referenceexamples/coercion/CMakeLists.txt b/examples/qml/referenceexamples/coercion/CMakeLists.txt
index cd93fa4883..b9613de116 100644
--- a/examples/qml/referenceexamples/coercion/CMakeLists.txt
+++ b/examples/qml/referenceexamples/coercion/CMakeLists.txt
@@ -32,17 +32,11 @@ target_link_libraries(coercion PUBLIC
Qt::Qml
)
-
-# Resources:
-set(coercion_resource_files
- "example.qml"
-)
-
-qt6_add_resources(coercion "coercion"
- PREFIX
- "/"
- FILES
- ${coercion_resource_files}
+qt_add_qml_module(coercion
+ URI People
+ VERSION 1.0
+ QML_FILES example.qml
+ NO_RESOURCE_TARGET_PATH
)
install(TARGETS coercion
@@ -50,10 +44,3 @@ install(TARGETS coercion
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
-
-set_target_properties(coercion PROPERTIES
- QT_QML_MODULE_VERSION 1.0
- QT_QML_MODULE_URI People
-)
-
-qt6_qml_type_registration(coercion)
diff --git a/examples/qml/referenceexamples/default/CMakeLists.txt b/examples/qml/referenceexamples/default/CMakeLists.txt
index 429fcb86ad..419b14d464 100644
--- a/examples/qml/referenceexamples/default/CMakeLists.txt
+++ b/examples/qml/referenceexamples/default/CMakeLists.txt
@@ -32,17 +32,11 @@ target_link_libraries(default PUBLIC
Qt::Qml
)
-
-# Resources:
-set(default_resource_files
- "example.qml"
-)
-
-qt6_add_resources(default "default"
- PREFIX
- "/"
- FILES
- ${default_resource_files}
+qt_add_qml_module(default
+ URI People
+ VERSION 1.0
+ QML_FILES example.qml
+ NO_RESOURCE_TARGET_PATH
)
install(TARGETS default
@@ -50,10 +44,3 @@ install(TARGETS default
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
-
-set_target_properties(default PROPERTIES
- QT_QML_MODULE_VERSION 1.0
- QT_QML_MODULE_URI People
-)
-
-qt6_qml_type_registration(default)
diff --git a/examples/qml/referenceexamples/extended/CMakeLists.txt b/examples/qml/referenceexamples/extended/CMakeLists.txt
index 87c750bea1..ea659e5f71 100644
--- a/examples/qml/referenceexamples/extended/CMakeLists.txt
+++ b/examples/qml/referenceexamples/extended/CMakeLists.txt
@@ -35,17 +35,11 @@ target_link_libraries(extended PUBLIC
Qt::Widgets
)
-
-# Resources:
-set(extended_resource_files
- "example.qml"
-)
-
-qt6_add_resources(extended "extended"
- PREFIX
- "/"
- FILES
- ${extended_resource_files}
+qt_add_qml_module(extended
+ URI People
+ VERSION 1.0
+ QML_FILES example.qml
+ NO_RESOURCE_TARGET_PATH
)
install(TARGETS extended
@@ -53,10 +47,3 @@ install(TARGETS extended
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
-
-set_target_properties(extended PROPERTIES
- QT_QML_MODULE_VERSION 1.0
- QT_QML_MODULE_URI People
-)
-
-qt6_qml_type_registration(extended)
diff --git a/examples/qml/referenceexamples/grouped/CMakeLists.txt b/examples/qml/referenceexamples/grouped/CMakeLists.txt
index c46d1beeb8..f7a31d9c1e 100644
--- a/examples/qml/referenceexamples/grouped/CMakeLists.txt
+++ b/examples/qml/referenceexamples/grouped/CMakeLists.txt
@@ -34,17 +34,11 @@ target_link_libraries(grouped PUBLIC
Qt::Qml
)
-
-# Resources:
-set(grouped_resource_files
- "example.qml"
-)
-
-qt6_add_resources(grouped "grouped"
- PREFIX
- "/"
- FILES
- ${grouped_resource_files}
+qt_add_qml_module(grouped
+ URI People
+ VERSION 1.0
+ QML_FILES example.qml
+ NO_RESOURCE_TARGET_PATH
)
install(TARGETS grouped
@@ -52,10 +46,3 @@ install(TARGETS grouped
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
-
-set_target_properties(grouped PROPERTIES
- QT_QML_MODULE_VERSION 1.0
- QT_QML_MODULE_URI People
-)
-
-qt6_qml_type_registration(grouped)
diff --git a/examples/qml/referenceexamples/methods/CMakeLists.txt b/examples/qml/referenceexamples/methods/CMakeLists.txt
index 0fc043fb8b..304aa3082a 100644
--- a/examples/qml/referenceexamples/methods/CMakeLists.txt
+++ b/examples/qml/referenceexamples/methods/CMakeLists.txt
@@ -32,17 +32,11 @@ target_link_libraries(methods PUBLIC
Qt::Qml
)
-
-# Resources:
-set(methods_resource_files
- "example.qml"
-)
-
-qt6_add_resources(methods "methods"
- PREFIX
- "/"
- FILES
- ${methods_resource_files}
+qt_add_qml_module(methods
+ URI People
+ VERSION 1.0
+ QML_FILES example.qml
+ NO_RESOURCE_TARGET_PATH
)
install(TARGETS methods
@@ -50,10 +44,3 @@ install(TARGETS methods
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
-
-set_target_properties(methods PROPERTIES
- QT_QML_MODULE_VERSION 1.0
- QT_QML_MODULE_URI People
-)
-
-qt6_qml_type_registration(methods)
diff --git a/examples/qml/referenceexamples/properties/CMakeLists.txt b/examples/qml/referenceexamples/properties/CMakeLists.txt
index 1f36559066..11f70f337f 100644
--- a/examples/qml/referenceexamples/properties/CMakeLists.txt
+++ b/examples/qml/referenceexamples/properties/CMakeLists.txt
@@ -32,17 +32,11 @@ target_link_libraries(properties PUBLIC
Qt::Qml
)
-
-# Resources:
-set(properties_resource_files
- "example.qml"
-)
-
-qt6_add_resources(properties "properties"
- PREFIX
- "/"
- FILES
- ${properties_resource_files}
+qt_add_qml_module(properties
+ URI People
+ VERSION 1.0
+ QML_FILES example.qml
+ NO_RESOURCE_TARGET_PATH
)
install(TARGETS properties
@@ -50,10 +44,3 @@ install(TARGETS properties
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
-
-set_target_properties(properties PROPERTIES
- QT_QML_MODULE_VERSION 1.0
- QT_QML_MODULE_URI People
-)
-
-qt6_qml_type_registration(properties)
diff --git a/examples/qml/referenceexamples/signal/CMakeLists.txt b/examples/qml/referenceexamples/signal/CMakeLists.txt
index 8e4cac00ce..23e494f7c9 100644
--- a/examples/qml/referenceexamples/signal/CMakeLists.txt
+++ b/examples/qml/referenceexamples/signal/CMakeLists.txt
@@ -34,17 +34,11 @@ target_link_libraries(signal PUBLIC
Qt::Qml
)
-
-# Resources:
-set(signal_resource_files
- "example.qml"
-)
-
-qt6_add_resources(signal "signal"
- PREFIX
- "/"
- FILES
- ${signal_resource_files}
+qt_add_qml_module(signal
+ URI People
+ VERSION 1.0
+ QML_FILES example.qml
+ NO_RESOURCE_TARGET_PATH
)
install(TARGETS signal
@@ -52,10 +46,3 @@ install(TARGETS signal
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
-
-set_target_properties(signal PROPERTIES
- QT_QML_MODULE_VERSION 1.0
- QT_QML_MODULE_URI People
-)
-
-qt6_qml_type_registration(signal)
diff --git a/examples/qml/referenceexamples/valuesource/CMakeLists.txt b/examples/qml/referenceexamples/valuesource/CMakeLists.txt
index f3653ac4e2..3e997bb8f8 100644
--- a/examples/qml/referenceexamples/valuesource/CMakeLists.txt
+++ b/examples/qml/referenceexamples/valuesource/CMakeLists.txt
@@ -35,17 +35,11 @@ target_link_libraries(valuesource PUBLIC
Qt::Qml
)
-
-# Resources:
-set(valuesource_resource_files
- "example.qml"
-)
-
-qt6_add_resources(valuesource "valuesource"
- PREFIX
- "/"
- FILES
- ${valuesource_resource_files}
+qt_add_qml_module(valuesource
+ URI People
+ VERSION 1.0
+ QML_FILES example.qml
+ NO_RESOURCE_TARGET_PATH
)
install(TARGETS valuesource
@@ -53,10 +47,3 @@ install(TARGETS valuesource
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
-
-set_target_properties(valuesource PROPERTIES
- QT_QML_MODULE_VERSION 1.0
- QT_QML_MODULE_URI People
-)
-
-qt6_qml_type_registration(valuesource)
diff --git a/examples/qml/tutorials/extending-qml/.prev_CMakeLists.txt b/examples/qml/tutorials/extending-qml/.prev_CMakeLists.txt
deleted file mode 100644
index 8e41f3d77d..0000000000
--- a/examples/qml/tutorials/extending-qml/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-# Generated from extending-qml.pro.
-
-add_subdirectory(chapter1-basics)
-add_subdirectory(chapter2-methods)
-add_subdirectory(chapter3-bindings)
-add_subdirectory(chapter4-customPropertyTypes)
-add_subdirectory(chapter5-listproperties)
-add_subdirectory(chapter6-plugins)
diff --git a/examples/qml/tutorials/extending-qml/chapter1-basics/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter1-basics/CMakeLists.txt
index 34e6c08fad..c04b465254 100644
--- a/examples/qml/tutorials/extending-qml/chapter1-basics/CMakeLists.txt
+++ b/examples/qml/tutorials/extending-qml/chapter1-basics/CMakeLists.txt
@@ -35,17 +35,11 @@ target_link_libraries(chapter1-basics PUBLIC
Qt::Quick
)
-
-# Resources:
-set(chapter1-basics_resource_files
- "app.qml"
-)
-
-qt6_add_resources(chapter1-basics "chapter1-basics"
- PREFIX
- "/"
- FILES
- ${chapter1-basics_resource_files}
+qt_add_qml_module(chapter1-basics
+ URI Charts
+ VERSION 1.0
+ QML_FILES app.qml
+ NO_RESOURCE_TARGET_PATH
)
install(TARGETS chapter1-basics
@@ -53,10 +47,3 @@ install(TARGETS chapter1-basics
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
-
-set_target_properties(chapter1-basics PROPERTIES
- QT_QML_MODULE_VERSION 1.0
- QT_QML_MODULE_URI Charts
-)
-
-qt6_qml_type_registration(chapter1-basics)
diff --git a/examples/qml/tutorials/extending-qml/chapter2-methods/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter2-methods/CMakeLists.txt
index 794c898741..993c235965 100644
--- a/examples/qml/tutorials/extending-qml/chapter2-methods/CMakeLists.txt
+++ b/examples/qml/tutorials/extending-qml/chapter2-methods/CMakeLists.txt
@@ -35,17 +35,11 @@ target_link_libraries(chapter2-methods PUBLIC
Qt::Quick
)
-
-# Resources:
-set(chapter2-methods_resource_files
- "app.qml"
-)
-
-qt6_add_resources(chapter2-methods "chapter2-methods"
- PREFIX
- "/"
- FILES
- ${chapter2-methods_resource_files}
+qt_add_qml_module(chapter2-methods
+ URI Charts
+ VERSION 1.0
+ QML_FILES app.qml
+ NO_RESOURCE_TARGET_PATH
)
install(TARGETS chapter2-methods
@@ -53,10 +47,3 @@ install(TARGETS chapter2-methods
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
-
-set_target_properties(chapter2-methods PROPERTIES
- QT_QML_MODULE_VERSION 1.0
- QT_QML_MODULE_URI Charts
-)
-
-qt6_qml_type_registration(chapter2-methods)
diff --git a/examples/qml/tutorials/extending-qml/chapter3-bindings/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter3-bindings/CMakeLists.txt
index d5d92ca13e..f600ae5389 100644
--- a/examples/qml/tutorials/extending-qml/chapter3-bindings/CMakeLists.txt
+++ b/examples/qml/tutorials/extending-qml/chapter3-bindings/CMakeLists.txt
@@ -35,17 +35,11 @@ target_link_libraries(chapter3-bindings PUBLIC
Qt::Quick
)
-
-# Resources:
-set(chapter3-bindings_resource_files
- "app.qml"
-)
-
-qt6_add_resources(chapter3-bindings "chapter3-bindings"
- PREFIX
- "/"
- FILES
- ${chapter3-bindings_resource_files}
+qt_add_qml_module(chapter3-bindings
+ URI Charts
+ VERSION 1.0
+ QML_FILES app.qml
+ NO_RESOURCE_TARGET_PATH
)
install(TARGETS chapter3-bindings
@@ -53,10 +47,3 @@ install(TARGETS chapter3-bindings
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
-
-set_target_properties(chapter3-bindings PROPERTIES
- QT_QML_MODULE_VERSION 1.0
- QT_QML_MODULE_URI Charts
-)
-
-qt6_qml_type_registration(chapter3-bindings)
diff --git a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/CMakeLists.txt
index 7011d39dfd..50e231bb7d 100644
--- a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/CMakeLists.txt
+++ b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/CMakeLists.txt
@@ -36,17 +36,11 @@ target_link_libraries(chapter4-customPropertyTypes PUBLIC
Qt::Quick
)
-
-# Resources:
-set(chapter4-customPropertyTypes_resource_files
- "app.qml"
-)
-
-qt6_add_resources(chapter4-customPropertyTypes "chapter4-customPropertyTypes"
- PREFIX
- "/"
- FILES
- ${chapter4-customPropertyTypes_resource_files}
+qt_add_qml_module(chapter4-customPropertyTypes
+ URI Charts
+ VERSION 1.0
+ QML_FILES app.qml
+ NO_RESOURCE_TARGET_PATH
)
install(TARGETS chapter4-customPropertyTypes
@@ -54,10 +48,3 @@ install(TARGETS chapter4-customPropertyTypes
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
-
-set_target_properties(chapter4-customPropertyTypes PROPERTIES
- QT_QML_MODULE_VERSION 1.0
- QT_QML_MODULE_URI Charts
-)
-
-qt6_qml_type_registration(chapter4-customPropertyTypes)
diff --git a/examples/qml/tutorials/extending-qml/chapter5-listproperties/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter5-listproperties/CMakeLists.txt
index 4fa74097e7..1891bc34d5 100644
--- a/examples/qml/tutorials/extending-qml/chapter5-listproperties/CMakeLists.txt
+++ b/examples/qml/tutorials/extending-qml/chapter5-listproperties/CMakeLists.txt
@@ -36,17 +36,11 @@ target_link_libraries(chapter5-listproperties PUBLIC
Qt::Quick
)
-
-# Resources:
-set(chapter5-listproperties_resource_files
- "app.qml"
-)
-
-qt6_add_resources(chapter5-listproperties "chapter5-listproperties"
- PREFIX
- "/"
- FILES
- ${chapter5-listproperties_resource_files}
+qt_add_qml_module(chapter5-listproperties
+ URI Charts
+ VERSION 1.0
+ QML_FILES app.qml
+ NO_RESOURCE_TARGET_PATH
)
install(TARGETS chapter5-listproperties
@@ -54,10 +48,3 @@ install(TARGETS chapter5-listproperties
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
-
-set_target_properties(chapter5-listproperties PROPERTIES
- QT_QML_MODULE_VERSION 1.0
- QT_QML_MODULE_URI Charts
-)
-
-qt6_qml_type_registration(chapter5-listproperties)
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/.prev_CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter6-plugins/.prev_CMakeLists.txt
deleted file mode 100644
index 0d68df497a..0000000000
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,51 +0,0 @@
-# Generated from chapter6-plugins.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(chapter6-plugins LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qml/tutorials/extending-qml/chapter6-plugins")
-
-find_package(Qt6 COMPONENTS Qml)
-find_package(Qt6 COMPONENTS Quick)
-
-qt_add_executable(chapter6-plugins
- main.cpp
-)
-set_target_properties(chapter6-plugins PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(chapter6-plugins PUBLIC
- Qt::Qml
- Qt::Quick
-)
-
-
-# Resources:
-set(app_resource_files
- "app.qml"
-)
-
-qt6_add_resources(chapter6-plugins "app"
- PREFIX
- "/"
- FILES
- ${app_resource_files}
-)
-
-install(TARGETS chapter6-plugins
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
-add_subdirectory(import)
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter6-plugins/CMakeLists.txt
index a85121d2f1..cf3d218c57 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/CMakeLists.txt
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/CMakeLists.txt
@@ -14,7 +14,6 @@ if(NOT DEFINED INSTALL_EXAMPLESDIR)
endif()
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qml/tutorials/extending-qml/chapter6-plugins")
-set(QT_QML_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
find_package(Qt6 COMPONENTS Qml)
find_package(Qt6 COMPONENTS Quick)
@@ -31,17 +30,11 @@ target_link_libraries(chapter6-plugins PUBLIC
Qt::Quick
)
-
-# Resources:
-set(app_resource_files
- "app.qml"
-)
-
-qt6_add_resources(chapter6-plugins "app"
- PREFIX
- "/"
- FILES
- ${app_resource_files}
+qt_add_qml_module(chapter6-plugins
+ URI ChartsApp
+ VERSION 1.0
+ QML_FILES app.qml
+ NO_RESOURCE_TARGET_PATH
)
install(TARGETS chapter6-plugins
@@ -50,4 +43,4 @@ install(TARGETS chapter6-plugins
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
-add_subdirectory(import)
+add_subdirectory(Charts)
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/CMakeLists.txt
index 15f6dcc2c2..15f6dcc2c2 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/CMakeLists.txt
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/CMakeLists.txt
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/import.pro b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/Charts.pro
index c37cd1fdee..054ed06606 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/import.pro
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/Charts.pro
@@ -17,10 +17,6 @@ SOURCES += piechart.cpp \
DESTPATH=$$[QT_INSTALL_EXAMPLES]/qml/tutorials/extending-qml/chapter6-plugins/$$QML_IMPORT_NAME
-copy_qmltypes.files = $$OUT_PWD/plugins.qmltypes
-copy_qmltypes.path = $$DESTDIR
-COPIES += copy_qmltypes
-
target.path=$$DESTPATH
qmldir.files=$$PWD/qmldir
qmldir.path=$$DESTPATH
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.h b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/chartsplugin.h
index 780bb3a8f3..780bb3a8f3 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.h
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/chartsplugin.h
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.cpp b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/piechart.cpp
index 536c0e16ae..536c0e16ae 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.cpp
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/piechart.cpp
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.h b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/piechart.h
index e6b768b274..e6b768b274 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.h
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/piechart.h
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/pieslice.cpp b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/pieslice.cpp
index 1d30036929..1d30036929 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/pieslice.cpp
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/pieslice.cpp
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/pieslice.h b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/pieslice.h
index 091870bd51..091870bd51 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/pieslice.h
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/pieslice.h
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/qmldir b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/qmldir
index d9e8471b3c..d9e8471b3c 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/qmldir
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/qmldir
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/chapter6-plugins.pro b/examples/qml/tutorials/extending-qml/chapter6-plugins/chapter6-plugins.pro
index f858c80876..2d78235454 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/chapter6-plugins.pro
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/chapter6-plugins.pro
@@ -1,5 +1,5 @@
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS = \
- import \
+ Charts \
app.pro
diff --git a/examples/qml/xmlhttprequest/CMakeLists.txt b/examples/qml/xmlhttprequest/CMakeLists.txt
index 8dc77d613c..71a33e7264 100644
--- a/examples/qml/xmlhttprequest/CMakeLists.txt
+++ b/examples/qml/xmlhttprequest/CMakeLists.txt
@@ -34,22 +34,21 @@ target_link_libraries(xmlhttprequest PUBLIC
Qt::Quick
)
-
-# Resources:
-set(xmlhttprequest_resource_files
- "Get.qml"
- "GetForm.ui.qml"
- "data.xml"
- "methods.js"
- "xmlhttprequest.qml"
+set(QT_QML_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/qml)
+qt_add_qml_module(xmlhttprequest
+ URI xmlhttprequest
+ VERSION 1.0
+ QML_FILES
+ Get.qml
+ GetForm.ui.qml
+ methods.js
+ xmlhttprequest.qml
+ RESOURCES
+ data.xml
+ RESOURCE_PREFIX /qml
)
-qt6_add_resources(xmlhttprequest "xmlhttprequest"
- PREFIX
- "/qml/xmlhttprequest"
- FILES
- ${xmlhttprequest_resource_files}
-)
+# These files live outside of the QML module, so add them separately
set(quick_shared_resource_files
"../../quick/shared/Button.qml"
"../../quick/shared/CheckBox.qml"