diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2024-04-03 12:30:23 +0200 |
|---|---|---|
| committer | Olivier De Cannière <olivier.decanniere@qt.io> | 2024-04-05 00:42:09 +0200 |
| commit | bb6cde5229bd15f6e233262ae46fffeda666cf3d (patch) | |
| tree | 78ae0d8207b8e54a51da7e1d85c345f7d8b80cb3 /examples/qml/tutorials/extending-qml/chapter2-methods | |
| parent | d049e07d3ef051175dc83fd9d9b4b7a82dd172f3 (diff) | |
Modernize "extending QML" tutorial
- Use qt_standard_project_setup()
- Don't use NO_RESOURCE_TARGET_PATH
- Use QQuickView::loadFromModule()
Pick-to: 6.7
Change-Id: Ie68fbcaaa8824ca1cfe186bc9ead905e705e97c7
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'examples/qml/tutorials/extending-qml/chapter2-methods')
| -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.txt | 7 | ||||
| -rw-r--r-- | examples/qml/tutorials/extending-qml/chapter2-methods/chapter2-methods.qrc | 5 | ||||
| -rw-r--r-- | examples/qml/tutorials/extending-qml/chapter2-methods/main.cpp | 2 | ||||
| -rw-r--r-- | examples/qml/tutorials/extending-qml/chapter2-methods/qmldir | 6 |
5 files changed, 13 insertions, 7 deletions
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 ca06de350a..3fc7d3ffbf 100644 --- a/examples/qml/tutorials/extending-qml/chapter2-methods/CMakeLists.txt +++ b/examples/qml/tutorials/extending-qml/chapter2-methods/CMakeLists.txt @@ -4,10 +4,10 @@ cmake_minimum_required(VERSION 3.16) project(chapter2-methods LANGUAGES CXX) -set(CMAKE_AUTOMOC ON) - 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 @@ -27,8 +27,7 @@ target_link_libraries(chapter2-methods PUBLIC qt_add_qml_module(chapter2-methods URI Charts - QML_FILES app.qml - NO_RESOURCE_TARGET_PATH + QML_FILES App.qml DEPENDENCIES QtQuick ) 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 + |
