aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qml/tutorials/extending-qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/qml/tutorials/extending-qml')
-rw-r--r--examples/qml/tutorials/extending-qml/CMakeLists.txt2
-rw-r--r--examples/qml/tutorials/extending-qml/chapter1-basics/App.qml (renamed from examples/qml/tutorials/extending-qml/chapter1-basics/app.qml)0
-rw-r--r--examples/qml/tutorials/extending-qml/chapter1-basics/CMakeLists.txt38
-rw-r--r--examples/qml/tutorials/extending-qml/chapter1-basics/chapter1-basics.qrc5
-rw-r--r--examples/qml/tutorials/extending-qml/chapter1-basics/main.cpp2
-rw-r--r--examples/qml/tutorials/extending-qml/chapter1-basics/qmldir6
-rw-r--r--examples/qml/tutorials/extending-qml/chapter2-methods/App.qml (renamed from examples/qml/tutorials/extending-qml/chapter2-methods/app.qml)0
-rw-r--r--examples/qml/tutorials/extending-qml/chapter2-methods/CMakeLists.txt38
-rw-r--r--examples/qml/tutorials/extending-qml/chapter2-methods/chapter2-methods.qrc5
-rw-r--r--examples/qml/tutorials/extending-qml/chapter2-methods/main.cpp2
-rw-r--r--examples/qml/tutorials/extending-qml/chapter2-methods/qmldir6
-rw-r--r--examples/qml/tutorials/extending-qml/chapter3-bindings/App.qml (renamed from examples/qml/tutorials/extending-qml/chapter3-bindings/app.qml)0
-rw-r--r--examples/qml/tutorials/extending-qml/chapter3-bindings/CMakeLists.txt38
-rw-r--r--examples/qml/tutorials/extending-qml/chapter3-bindings/chapter3-bindings.qrc5
-rw-r--r--examples/qml/tutorials/extending-qml/chapter3-bindings/main.cpp2
-rw-r--r--examples/qml/tutorials/extending-qml/chapter3-bindings/qmldir6
-rw-r--r--examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/App.qml (renamed from examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/app.qml)0
-rw-r--r--examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/CMakeLists.txt37
-rw-r--r--examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/chapter4-customPropertyTypes.qrc5
-rw-r--r--examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/main.cpp2
-rw-r--r--examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/qmldir6
-rw-r--r--examples/qml/tutorials/extending-qml/chapter5-listproperties/App.qml (renamed from examples/qml/tutorials/extending-qml/chapter5-listproperties/app.qml)0
-rw-r--r--examples/qml/tutorials/extending-qml/chapter5-listproperties/CMakeLists.txt38
-rw-r--r--examples/qml/tutorials/extending-qml/chapter5-listproperties/chapter5-listproperties.qrc5
-rw-r--r--examples/qml/tutorials/extending-qml/chapter5-listproperties/main.cpp2
-rw-r--r--examples/qml/tutorials/extending-qml/chapter5-listproperties/qmldir6
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/App.qml (renamed from examples/qml/tutorials/extending-qml/chapter6-plugins/app.qml)0
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/CMakeLists.txt37
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/CMakeLists.txt42
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/qmldir5
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/app.qrc5
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/main.cpp4
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/qmldir3
33 files changed, 192 insertions, 160 deletions
diff --git a/examples/qml/tutorials/extending-qml/CMakeLists.txt b/examples/qml/tutorials/extending-qml/CMakeLists.txt
index f5fc6e5cfe..87e3eaf54d 100644
--- a/examples/qml/tutorials/extending-qml/CMakeLists.txt
+++ b/examples/qml/tutorials/extending-qml/CMakeLists.txt
@@ -1,5 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
qt_internal_add_example(chapter1-basics)
qt_internal_add_example(chapter2-methods)
diff --git a/examples/qml/tutorials/extending-qml/chapter1-basics/app.qml b/examples/qml/tutorials/extending-qml/chapter1-basics/App.qml
index ed89ce97c4..ed89ce97c4 100644
--- a/examples/qml/tutorials/extending-qml/chapter1-basics/app.qml
+++ b/examples/qml/tutorials/extending-qml/chapter1-basics/App.qml
diff --git a/examples/qml/tutorials/extending-qml/chapter1-basics/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter1-basics/CMakeLists.txt
index 02ed972ef5..0080197766 100644
--- a/examples/qml/tutorials/extending-qml/chapter1-basics/CMakeLists.txt
+++ b/examples/qml/tutorials/extending-qml/chapter1-basics/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(chapter1-basics LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qml/tutorials/extending-qml/chapter1-basics")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick)
+qt_standard_project_setup(REQUIRES 6.5)
+
qt_add_executable(chapter1-basics
main.cpp
piechart.cpp piechart.h
@@ -25,21 +19,29 @@ set_target_properties(chapter1-basics PROPERTIES
)
target_link_libraries(chapter1-basics PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Qml
- Qt::Quick
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Qml
+ Qt6::Quick
)
#![0]
qt_add_qml_module(chapter1-basics
URI Charts
- QML_FILES app.qml
- NO_RESOURCE_TARGET_PATH
+ QML_FILES App.qml
DEPENDENCIES QtQuick
)
#![0]
install(TARGETS chapter1-basics
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_qml_app_script(
+ TARGET chapter1-basics
+ OUTPUT_SCRIPT deploy_script
+ MACOS_BUNDLE_POST_BUILD
+ NO_UNSUPPORTED_PLATFORM_ERROR
+ DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/qml/tutorials/extending-qml/chapter1-basics/chapter1-basics.qrc b/examples/qml/tutorials/extending-qml/chapter1-basics/chapter1-basics.qrc
index f1168aef3b..c72f203e67 100644
--- a/examples/qml/tutorials/extending-qml/chapter1-basics/chapter1-basics.qrc
+++ b/examples/qml/tutorials/extending-qml/chapter1-basics/chapter1-basics.qrc
@@ -1,5 +1,6 @@
<RCC>
- <qresource prefix="/">
- <file>app.qml</file>
+ <qresource prefix="/qt/qml/Charts">
+ <file>App.qml</file>
+ <file>qmldir</file>
</qresource>
</RCC>
diff --git a/examples/qml/tutorials/extending-qml/chapter1-basics/main.cpp b/examples/qml/tutorials/extending-qml/chapter1-basics/main.cpp
index f2eaab03bc..bc4bbba809 100644
--- a/examples/qml/tutorials/extending-qml/chapter1-basics/main.cpp
+++ b/examples/qml/tutorials/extending-qml/chapter1-basics/main.cpp
@@ -11,7 +11,7 @@ int main(int argc, char *argv[])
QQuickView view;
view.setResizeMode(QQuickView::SizeRootObjectToView);
- view.setSource(QUrl("qrc:///app.qml"));
+ view.loadFromModule("Charts", "App");
view.show();
return QGuiApplication::exec();
}
diff --git a/examples/qml/tutorials/extending-qml/chapter1-basics/qmldir b/examples/qml/tutorials/extending-qml/chapter1-basics/qmldir
new file mode 100644
index 0000000000..f69878a753
--- /dev/null
+++ b/examples/qml/tutorials/extending-qml/chapter1-basics/qmldir
@@ -0,0 +1,6 @@
+module Charts
+typeinfo chapter1-basics.qmltypes
+depends QtQuick
+prefer :/qt/qml/Charts/
+App 254.0 App.qml
+
diff --git a/examples/qml/tutorials/extending-qml/chapter2-methods/app.qml b/examples/qml/tutorials/extending-qml/chapter2-methods/App.qml
index 56597c3f42..56597c3f42 100644
--- a/examples/qml/tutorials/extending-qml/chapter2-methods/app.qml
+++ b/examples/qml/tutorials/extending-qml/chapter2-methods/App.qml
diff --git a/examples/qml/tutorials/extending-qml/chapter2-methods/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter2-methods/CMakeLists.txt
index f0906cf380..3fc7d3ffbf 100644
--- a/examples/qml/tutorials/extending-qml/chapter2-methods/CMakeLists.txt
+++ b/examples/qml/tutorials/extending-qml/chapter2-methods/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(chapter2-methods LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qml/tutorials/extending-qml/chapter2-methods")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick)
+qt_standard_project_setup(REQUIRES 6.5)
+
qt_add_executable(chapter2-methods
main.cpp
piechart.cpp piechart.h
@@ -25,21 +19,29 @@ set_target_properties(chapter2-methods PROPERTIES
)
target_link_libraries(chapter2-methods PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Qml
- Qt::Quick
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Qml
+ Qt6::Quick
)
qt_add_qml_module(chapter2-methods
URI Charts
- QML_FILES app.qml
- NO_RESOURCE_TARGET_PATH
+ QML_FILES App.qml
DEPENDENCIES QtQuick
)
install(TARGETS chapter2-methods
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_qml_app_script(
+ TARGET chapter2-methods
+ OUTPUT_SCRIPT deploy_script
+ MACOS_BUNDLE_POST_BUILD
+ NO_UNSUPPORTED_PLATFORM_ERROR
+ DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/qml/tutorials/extending-qml/chapter2-methods/chapter2-methods.qrc b/examples/qml/tutorials/extending-qml/chapter2-methods/chapter2-methods.qrc
index f1168aef3b..c72f203e67 100644
--- a/examples/qml/tutorials/extending-qml/chapter2-methods/chapter2-methods.qrc
+++ b/examples/qml/tutorials/extending-qml/chapter2-methods/chapter2-methods.qrc
@@ -1,5 +1,6 @@
<RCC>
- <qresource prefix="/">
- <file>app.qml</file>
+ <qresource prefix="/qt/qml/Charts">
+ <file>App.qml</file>
+ <file>qmldir</file>
</qresource>
</RCC>
diff --git a/examples/qml/tutorials/extending-qml/chapter2-methods/main.cpp b/examples/qml/tutorials/extending-qml/chapter2-methods/main.cpp
index f2eaab03bc..bc4bbba809 100644
--- a/examples/qml/tutorials/extending-qml/chapter2-methods/main.cpp
+++ b/examples/qml/tutorials/extending-qml/chapter2-methods/main.cpp
@@ -11,7 +11,7 @@ int main(int argc, char *argv[])
QQuickView view;
view.setResizeMode(QQuickView::SizeRootObjectToView);
- view.setSource(QUrl("qrc:///app.qml"));
+ view.loadFromModule("Charts", "App");
view.show();
return QGuiApplication::exec();
}
diff --git a/examples/qml/tutorials/extending-qml/chapter2-methods/qmldir b/examples/qml/tutorials/extending-qml/chapter2-methods/qmldir
new file mode 100644
index 0000000000..e8b0c98311
--- /dev/null
+++ b/examples/qml/tutorials/extending-qml/chapter2-methods/qmldir
@@ -0,0 +1,6 @@
+module Charts
+typeinfo chapter2-methods.qmltypes
+depends QtQuick
+prefer :/qt/qml/Charts/
+App 254.0 App.qml
+
diff --git a/examples/qml/tutorials/extending-qml/chapter3-bindings/app.qml b/examples/qml/tutorials/extending-qml/chapter3-bindings/App.qml
index d29eaf4b9f..d29eaf4b9f 100644
--- a/examples/qml/tutorials/extending-qml/chapter3-bindings/app.qml
+++ b/examples/qml/tutorials/extending-qml/chapter3-bindings/App.qml
diff --git a/examples/qml/tutorials/extending-qml/chapter3-bindings/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter3-bindings/CMakeLists.txt
index 05c567fd30..a842eb48ca 100644
--- a/examples/qml/tutorials/extending-qml/chapter3-bindings/CMakeLists.txt
+++ b/examples/qml/tutorials/extending-qml/chapter3-bindings/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(chapter3-bindings LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qml/tutorials/extending-qml/chapter3-bindings")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick)
+qt_standard_project_setup(REQUIRES 6.5)
+
qt_add_executable(chapter3-bindings
main.cpp
piechart.cpp piechart.h
@@ -25,21 +19,29 @@ set_target_properties(chapter3-bindings PROPERTIES
)
target_link_libraries(chapter3-bindings PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Qml
- Qt::Quick
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Qml
+ Qt6::Quick
)
qt_add_qml_module(chapter3-bindings
URI Charts
- QML_FILES app.qml
- NO_RESOURCE_TARGET_PATH
+ QML_FILES App.qml
DEPENDENCIES QtQuick
)
install(TARGETS chapter3-bindings
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_qml_app_script(
+ TARGET chapter3-bindings
+ OUTPUT_SCRIPT deploy_script
+ MACOS_BUNDLE_POST_BUILD
+ NO_UNSUPPORTED_PLATFORM_ERROR
+ DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/qml/tutorials/extending-qml/chapter3-bindings/chapter3-bindings.qrc b/examples/qml/tutorials/extending-qml/chapter3-bindings/chapter3-bindings.qrc
index f1168aef3b..c72f203e67 100644
--- a/examples/qml/tutorials/extending-qml/chapter3-bindings/chapter3-bindings.qrc
+++ b/examples/qml/tutorials/extending-qml/chapter3-bindings/chapter3-bindings.qrc
@@ -1,5 +1,6 @@
<RCC>
- <qresource prefix="/">
- <file>app.qml</file>
+ <qresource prefix="/qt/qml/Charts">
+ <file>App.qml</file>
+ <file>qmldir</file>
</qresource>
</RCC>
diff --git a/examples/qml/tutorials/extending-qml/chapter3-bindings/main.cpp b/examples/qml/tutorials/extending-qml/chapter3-bindings/main.cpp
index f2eaab03bc..bc4bbba809 100644
--- a/examples/qml/tutorials/extending-qml/chapter3-bindings/main.cpp
+++ b/examples/qml/tutorials/extending-qml/chapter3-bindings/main.cpp
@@ -11,7 +11,7 @@ int main(int argc, char *argv[])
QQuickView view;
view.setResizeMode(QQuickView::SizeRootObjectToView);
- view.setSource(QUrl("qrc:///app.qml"));
+ view.loadFromModule("Charts", "App");
view.show();
return QGuiApplication::exec();
}
diff --git a/examples/qml/tutorials/extending-qml/chapter3-bindings/qmldir b/examples/qml/tutorials/extending-qml/chapter3-bindings/qmldir
new file mode 100644
index 0000000000..f0911d3c89
--- /dev/null
+++ b/examples/qml/tutorials/extending-qml/chapter3-bindings/qmldir
@@ -0,0 +1,6 @@
+module Charts
+typeinfo chapter3-bindings.qmltypes
+depends QtQuick
+prefer :/qt/qml/Charts/
+App 254.0 App.qml
+
diff --git a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/app.qml b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/App.qml
index 2edcda568e..2edcda568e 100644
--- a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/app.qml
+++ b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/App.qml
diff --git a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/CMakeLists.txt
index 3914819640..fd6428093b 100644
--- a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/CMakeLists.txt
+++ b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/CMakeLists.txt
@@ -1,18 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(chapter4-customPropertyTypes LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick)
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qml/tutorials/extending-qml/chapter4-customPropertyTypes")
+qt_standard_project_setup(REQUIRES 6.5)
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick)
#![0]
qt_add_executable(chapter4-customPropertyTypes
main.cpp
@@ -26,21 +21,29 @@ set_target_properties(chapter4-customPropertyTypes PROPERTIES
)
target_link_libraries(chapter4-customPropertyTypes PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Qml
- Qt::Quick
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Qml
+ Qt6::Quick
)
#![1]
qt_add_qml_module(chapter4-customPropertyTypes
URI Charts
- QML_FILES app.qml
- NO_RESOURCE_TARGET_PATH
+ QML_FILES App.qml
DEPENDENCIES QtQuick
)
#![1]
install(TARGETS chapter4-customPropertyTypes
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_qml_app_script(
+ TARGET chapter4-customPropertyTypes
+ OUTPUT_SCRIPT deploy_script
+ MACOS_BUNDLE_POST_BUILD
+ NO_UNSUPPORTED_PLATFORM_ERROR
+ DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/chapter4-customPropertyTypes.qrc b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/chapter4-customPropertyTypes.qrc
index f1168aef3b..c72f203e67 100644
--- a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/chapter4-customPropertyTypes.qrc
+++ b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/chapter4-customPropertyTypes.qrc
@@ -1,5 +1,6 @@
<RCC>
- <qresource prefix="/">
- <file>app.qml</file>
+ <qresource prefix="/qt/qml/Charts">
+ <file>App.qml</file>
+ <file>qmldir</file>
</qresource>
</RCC>
diff --git a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/main.cpp b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/main.cpp
index 8833750ebf..09a025ae85 100644
--- a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/main.cpp
+++ b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/main.cpp
@@ -14,7 +14,7 @@ int main(int argc, char *argv[])
QQuickView view;
view.setResizeMode(QQuickView::SizeRootObjectToView);
- view.setSource(QUrl("qrc:///app.qml"));
+ view.loadFromModule("Charts", "App");
view.show();
return QGuiApplication::exec();
diff --git a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/qmldir b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/qmldir
new file mode 100644
index 0000000000..14c64f5269
--- /dev/null
+++ b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/qmldir
@@ -0,0 +1,6 @@
+module Charts
+typeinfo chapter4-customPropertyTypes.qmltypes
+depends QtQuick
+prefer :/qt/qml/Charts/
+App 254.0 App.qml
+
diff --git a/examples/qml/tutorials/extending-qml/chapter5-listproperties/app.qml b/examples/qml/tutorials/extending-qml/chapter5-listproperties/App.qml
index 9e200a9b60..9e200a9b60 100644
--- a/examples/qml/tutorials/extending-qml/chapter5-listproperties/app.qml
+++ b/examples/qml/tutorials/extending-qml/chapter5-listproperties/App.qml
diff --git a/examples/qml/tutorials/extending-qml/chapter5-listproperties/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter5-listproperties/CMakeLists.txt
index d3b70f2017..73984849c0 100644
--- a/examples/qml/tutorials/extending-qml/chapter5-listproperties/CMakeLists.txt
+++ b/examples/qml/tutorials/extending-qml/chapter5-listproperties/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(chapter5-listproperties LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qml/tutorials/extending-qml/chapter5-listproperties")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick)
+qt_standard_project_setup(REQUIRES 6.5)
+
qt_add_executable(chapter5-listproperties
main.cpp
piechart.cpp piechart.h
@@ -26,21 +20,29 @@ set_target_properties(chapter5-listproperties PROPERTIES
)
target_link_libraries(chapter5-listproperties PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Qml
- Qt::Quick
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Qml
+ Qt6::Quick
)
qt_add_qml_module(chapter5-listproperties
URI Charts
- QML_FILES app.qml
- NO_RESOURCE_TARGET_PATH
+ QML_FILES App.qml
DEPENDENCIES QtQuick
)
install(TARGETS chapter5-listproperties
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_qml_app_script(
+ TARGET chapter5-listproperties
+ OUTPUT_SCRIPT deploy_script
+ MACOS_BUNDLE_POST_BUILD
+ NO_UNSUPPORTED_PLATFORM_ERROR
+ DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/qml/tutorials/extending-qml/chapter5-listproperties/chapter5-listproperties.qrc b/examples/qml/tutorials/extending-qml/chapter5-listproperties/chapter5-listproperties.qrc
index f1168aef3b..c72f203e67 100644
--- a/examples/qml/tutorials/extending-qml/chapter5-listproperties/chapter5-listproperties.qrc
+++ b/examples/qml/tutorials/extending-qml/chapter5-listproperties/chapter5-listproperties.qrc
@@ -1,5 +1,6 @@
<RCC>
- <qresource prefix="/">
- <file>app.qml</file>
+ <qresource prefix="/qt/qml/Charts">
+ <file>App.qml</file>
+ <file>qmldir</file>
</qresource>
</RCC>
diff --git a/examples/qml/tutorials/extending-qml/chapter5-listproperties/main.cpp b/examples/qml/tutorials/extending-qml/chapter5-listproperties/main.cpp
index 3d11a689a6..12d4d49438 100644
--- a/examples/qml/tutorials/extending-qml/chapter5-listproperties/main.cpp
+++ b/examples/qml/tutorials/extending-qml/chapter5-listproperties/main.cpp
@@ -12,7 +12,7 @@ int main(int argc, char *argv[])
QQuickView view;
view.setResizeMode(QQuickView::SizeRootObjectToView);
- view.setSource(QUrl("qrc:///app.qml"));
+ view.loadFromModule("Charts", "App");
view.show();
return QGuiApplication::exec();
}
diff --git a/examples/qml/tutorials/extending-qml/chapter5-listproperties/qmldir b/examples/qml/tutorials/extending-qml/chapter5-listproperties/qmldir
new file mode 100644
index 0000000000..cebd0320ab
--- /dev/null
+++ b/examples/qml/tutorials/extending-qml/chapter5-listproperties/qmldir
@@ -0,0 +1,6 @@
+module Charts
+typeinfo chapter5-listproperties.qmltypes
+depends QtQuick
+prefer :/qt/qml/Charts/
+App 254.0 App.qml
+
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/app.qml b/examples/qml/tutorials/extending-qml/chapter6-plugins/App.qml
index 1d1cb74176..1d1cb74176 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/app.qml
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/App.qml
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter6-plugins/CMakeLists.txt
index f1a7ef1b51..bd88766e0c 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/CMakeLists.txt
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(chapter6-plugins LANGUAGES CXX)
-set(CMAKE_AUTOMOC 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 REQUIRED COMPONENTS Qml Quick)
+qt_standard_project_setup(REQUIRES 6.5)
+
qt_add_executable(chapter6-plugins
main.cpp
)
@@ -24,20 +18,29 @@ set_target_properties(chapter6-plugins PROPERTIES
)
target_link_libraries(chapter6-plugins PRIVATE
- Qt::Qml
- Qt::Quick
+ Qt6::Qml
+ Qt6::Quick
)
qt_add_qml_module(chapter6-plugins
URI ChartsApp
- QML_FILES app.qml
- NO_RESOURCE_TARGET_PATH
+ QML_FILES App.qml
)
+add_subdirectory(Charts)
+
install(TARGETS chapter6-plugins
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
-add_subdirectory(Charts)
+qt_generate_deploy_qml_app_script(
+ TARGET chapter6-plugins
+ OUTPUT_SCRIPT deploy_script
+ MACOS_BUNDLE_POST_BUILD
+ NO_UNSUPPORTED_PLATFORM_ERROR
+ DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM
+)
+install(SCRIPT ${deploy_script})
+
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/CMakeLists.txt
index 4a8f2e0b7b..a0fed166e0 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/CMakeLists.txt
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/CMakeLists.txt
@@ -1,5 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
qt6_policy(SET QTP0001 NEW)
qt6_add_qml_module(chartsplugin
@@ -14,40 +14,16 @@ target_sources(chartsplugin PRIVATE
)
target_link_libraries(chartsplugin PRIVATE
- Qt::Core
- Qt::Gui
- Qt::Qml
- Qt::Quick
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Qml
+ Qt6::Quick
)
-if(QT6_IS_SHARED_LIBS_BUILD AND APPLE)
- get_target_property(is_bundle chapter6-plugins MACOSX_BUNDLE)
- if(is_bundle)
- # The application's main.cpp adds an explicit QML import path to look for qml modules under
- # a PlugIns subdirectory in a macOS bundle.
- # Copy the qmldir and shared library qml plugin.
-
- set(charts_dir "$<TARGET_FILE_DIR:chartsplugin>")
- set(chars_qmldir_file "${charts_dir}/qmldir")
- set(app_dir "$<TARGET_FILE_DIR:chapter6-plugins>")
- set(bundle_charts_dir "${app_dir}/../PlugIns/Charts")
-
- add_custom_command(TARGET chartsplugin POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E make_directory ${bundle_charts_dir}
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- $<TARGET_FILE:chartsplugin> ${bundle_charts_dir}
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- ${chars_qmldir_file} ${bundle_charts_dir}
- VERBATIM
- )
- endif()
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLEDIR}/Charts")
install(TARGETS chartsplugin
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/Charts"
+ LIBRARY DESTINATION "${CMAKE_INSTALL_BINDIR}/Charts"
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qmldir
- DESTINATION "${INSTALL_EXAMPLEDIR}")
+ DESTINATION "${CMAKE_INSTALL_BINDIR}/Charts"
+)
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/qmldir b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/qmldir
index d9e8471b3c..4536f60e91 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/qmldir
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/qmldir
@@ -1,2 +1,5 @@
module Charts
-plugin chartsplugin
+optional plugin chartsplugin
+typeinfo plugins.qmltypes
+depends QtQuick
+prefer :/qt/qml/Charts/
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/app.qrc b/examples/qml/tutorials/extending-qml/chapter6-plugins/app.qrc
index f1168aef3b..5c4567d0d9 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/app.qrc
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/app.qrc
@@ -1,5 +1,6 @@
<RCC>
- <qresource prefix="/">
- <file>app.qml</file>
+ <qresource prefix="/qt/qml/ChartsApp">
+ <file>App.qml</file>
+ <file>qmldir</file>
</qresource>
</RCC>
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/main.cpp b/examples/qml/tutorials/extending-qml/chapter6-plugins/main.cpp
index 3475401ebd..7dfb1cf5a7 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/main.cpp
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/main.cpp
@@ -9,12 +9,12 @@ int main(int argc, char *argv[])
QGuiApplication app(argc, argv);
//![0]
QQuickView view;
-#ifdef Q_OS_OSX
+#ifdef Q_OS_MACOS
view.engine()->addImportPath(app.applicationDirPath() + "/../PlugIns");
#endif
//![0]
view.setResizeMode(QQuickView::SizeRootObjectToView);
- view.setSource(QUrl("qrc:///app.qml"));
+ view.loadFromModule("ChartsApp", "App");
view.show();
return app.exec();
}
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/qmldir b/examples/qml/tutorials/extending-qml/chapter6-plugins/qmldir
new file mode 100644
index 0000000000..d7fa4b260b
--- /dev/null
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/qmldir
@@ -0,0 +1,3 @@
+module ChartsApp
+prefer :/qt/qml/ChartsApp/
+App 254.0 App.qml