From cb5131d5e9b5ddd8dd6080fc96fbd96ce83f5ee3 Mon Sep 17 00:00:00 2001 From: Oliver Eftevaag Date: Mon, 6 Sep 2021 15:04:46 +0200 Subject: Fix layouts example to use a QML module Changing the CMakeLists.txt file to use qt_add_qml_module(). Change-Id: Icafe9359494136af6d5f3befaa9e767ab12deb30 Reviewed-by: Mitch Curtis (cherry picked from commit 2cd4391ba0c214d26ebf9298a0130b17c588a8c2) Reviewed-by: Qt Cherry-pick Bot --- examples/quick/layouts/CMakeLists.txt | 37 ++++++++++++----------------------- examples/quick/layouts/layouts.qml | 8 ++++---- 2 files changed, 17 insertions(+), 28 deletions(-) diff --git a/examples/quick/layouts/CMakeLists.txt b/examples/quick/layouts/CMakeLists.txt index f2c70c97d9..dc9bf06e66 100644 --- a/examples/quick/layouts/CMakeLists.txt +++ b/examples/quick/layouts/CMakeLists.txt @@ -7,7 +7,6 @@ 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") @@ -15,39 +14,29 @@ endif() set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/layouts") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Qml) -find_package(Qt6 COMPONENTS Quick) +find_package(Qt6 COMPONENTS Core Gui Qml Quick) -qt_add_executable(layouts +qt_add_executable(layoutsexample + WIN32 + MACOSX_BUNDLE main.cpp ) -set_target_properties(layouts PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE + +qt_add_qml_module(layoutsexample + URI layouts + VERSION 1.0 + QML_FILES + "layouts.qml" ) -target_link_libraries(layouts PUBLIC + +target_link_libraries(layoutsexample PUBLIC Qt::Core Qt::Gui Qt::Qml Qt::Quick ) - -# Resources: -set(layouts_resource_files - "layouts.qml" -) - -qt6_add_resources(layouts "layouts" - PREFIX - "/layouts" - FILES - ${layouts_resource_files} -) - -install(TARGETS layouts +install(TARGETS layoutsexample RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" diff --git a/examples/quick/layouts/layouts.qml b/examples/quick/layouts/layouts.qml index 8a1cb20d22..423b670b06 100644 --- a/examples/quick/layouts/layouts.qml +++ b/examples/quick/layouts/layouts.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2020 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -48,9 +48,9 @@ ** ****************************************************************************/ -import QtQuick 2.2 -import QtQuick.Controls 2.12 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts ApplicationWindow { id: appWindow -- cgit v1.2.3