diff options
Diffstat (limited to 'examples/qml/tutorials/extending-qml/chapter6-plugins')
-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.txt | 37 | ||||
-rw-r--r-- | examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/CMakeLists.txt | 42 | ||||
-rw-r--r-- | examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/qmldir | 5 | ||||
-rw-r--r-- | examples/qml/tutorials/extending-qml/chapter6-plugins/app.qrc | 5 | ||||
-rw-r--r-- | examples/qml/tutorials/extending-qml/chapter6-plugins/main.cpp | 4 | ||||
-rw-r--r-- | examples/qml/tutorials/extending-qml/chapter6-plugins/qmldir | 3 |
7 files changed, 41 insertions, 55 deletions
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 |