diff options
author | Craig Scott <craig.scott@qt.io> | 2021-08-23 16:29:18 +1000 |
---|---|---|
committer | Craig Scott <craig.scott@qt.io> | 2021-08-24 16:08:21 +1000 |
commit | 9e1d2a0eb15487f8f2acb4d91b281568897fb4e1 (patch) | |
tree | e055ea022161b4dbbecbb94c2c1fa7c4a83a5ee8 /examples/qml/tutorials/extending-qml | |
parent | 05bee5bb50378b76b6441895c533f50d99db445e (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
Pick-to: 6.2
Change-Id: Ie3399410cf6df491eb1e7b4a589ca26c577d82a0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'examples/qml/tutorials/extending-qml')
17 files changed, 32 insertions, 167 deletions
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 fbded1e3a2..fbded1e3a2 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 86602afe8f..86602afe8f 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 |