diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2023-02-21 16:20:11 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-02-24 11:31:35 +0000 |
commit | fd0d36dbf7492dd409ce0c0c1723408bdc396768 (patch) | |
tree | 9bdea8ce679a2fc8fca5e3549d720a4f498d435c | |
parent | 263e4faf4392a54a3e448a7cc5c7b80653f267a4 (diff) | |
download | qtdoc-fd0d36dbf7492dd409ce0c0c1723408bdc396768.tar.gz |
Update Building a QML application for 6.5
- se qt_standard_project_setup instead of AUTOMOC
- pass REQUIRED 6.5 to it
- adjust the resource path URL accordingly
- Group all content describing the effect of qt_add_qml_module together
As a drive-by, also pass REQUIRED 6.5 to qt_standard_project_setup in
the "Reusable QML module" section.
Task-number: QTBUG-109799
Change-Id: Ia10b0d9a3010d8653f15b626fb1828ebafade186
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit c4c75c8f378e2562a19745e1eb6855480114edf5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | doc/src/cmake/cmake-manual.qdoc | 32 | ||||
-rw-r--r-- | doc/src/cmake/snippets/cmake/helloworld_qtqml.cmake | 7 |
2 files changed, 20 insertions, 19 deletions
diff --git a/doc/src/cmake/cmake-manual.qdoc b/doc/src/cmake/cmake-manual.qdoc index c9730b28..e237d070 100644 --- a/doc/src/cmake/cmake-manual.qdoc +++ b/doc/src/cmake/cmake-manual.qdoc @@ -506,20 +506,23 @@ \printuntil Let's walk through the changes we have made. - We specify \l {Building a C++ GUI application}{CMAKE_AUTOMOC}, - \l{Building a C++ console application}{CMAKE_CXX_STANDARD}, - and CMAKE_CXX_STANDARD_REQUIRED. - - \quotefromfile snippets/cmake/helloworld_qtqml.cmake - \skipto CMAKE_AUTOMOC - \printuntil CMAKE_CXX_STANDARD_REQUIRED - In the \c{find_package} call, we replace \c{Core} with \c{Quick}. This will locate the \c{Qt6Quick} module and provide the \c{Qt6::Quick} targets we later link against. + \quotefromfile snippets/cmake/helloworld_qtqml.cmake + \skipto find_package( \printuntil find_package( + We call \l {qt6_standard_project_setup}{qt_standard_project_setup}, + and specify \l{Building a C++ console application}{CMAKE_CXX_STANDARD}, + and \c{CMAKE_CXX_STANDARD_REQUIRED}. + By passing \c {REQUIRED 6.5} to \c {qt_standard_project_setup}, we opt-in + to useful defaults for \l{qt6_add_qml_module}{qt_add_qml_module}. + + \printuntil CMAKE_CXX_STANDARD_REQUIRED + + Note that the application will still link against \c{Qt6::Core}, because \c{Qt6::Quick} depends on it. @@ -529,15 +532,14 @@ \l {qt_add_qml_module} passes the target of the executable, a URI, module version, and a list of QML files to ensure that myapp becomes a - QML module. Among other things, this places the QML files into - \c { qrc:/${URI} } in the resource file system. + QML module. This places the QML files into + \c { qrc:/qt/qml/${URI} } in the resource file system. + Moreover, \c qt_add_qml_module ensures that \c qmlcachegen runs. + Additionally, it creates a \c myapp_qmllint target, which runs \c qmllint on + the files in QML_FILES. \printuntil ) - First, \c qt_add_qml_module ensures that \c qmlcachegen runs. Second, it - creates a \c myapp_qmllint target, which runs \c qmllint on the files in - QML_FILES. - By adding the referenced resources, they get automatically added to the application under the same root path as the QML files – also in the resource file system. By keeping the path in the resource system @@ -584,7 +586,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(Qt6 REQUIRED COMPONENTS Qml) - qt_standard_project_setup() + qt_standard_project_setup(REQUIRED 6.5) add_subdirectory(example/mylib) \endcode diff --git a/doc/src/cmake/snippets/cmake/helloworld_qtqml.cmake b/doc/src/cmake/snippets/cmake/helloworld_qtqml.cmake index 6699efb1..feb290e9 100644 --- a/doc/src/cmake/snippets/cmake/helloworld_qtqml.cmake +++ b/doc/src/cmake/snippets/cmake/helloworld_qtqml.cmake @@ -5,19 +5,18 @@ cmake_minimum_required(VERSION 3.16) project(hello VERSION 1.0 LANGUAGES CXX) -set(CMAKE_AUTOMOC ON) +find_package(Qt6 6.2 COMPONENTS Quick Gui REQUIRED) + +qt_standard_project_setup(REQUIRED 6.5) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -find_package(Qt6 6.2 COMPONENTS Quick Gui REQUIRED) - qt_add_executable(myapp main.cpp ) qt_add_qml_module(myapp URI hello - VERSION 1.0 QML_FILES main.qml FramedImage.qml |