DragAndDrop example: Update CMakeLists.txt

This commit updates the drag and drop example to use qt_add_qml_module()
in its CMakeLists.txt file.

Pick-to: 6.2
Change-Id: I47fd28a1a114fe70986f73d4f2d87265255652a0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Oliver Eftevaag 2021-09-06 11:25:52 +02:00
parent 5ff83606a1
commit b128136f80
4 changed files with 31 additions and 61 deletions

View File

@ -54,6 +54,7 @@ set(reused_dir_targets
imageelements_shared
delegatechooser_shared
pointerhandlers_shared
draganddrop_shared
)
foreach(target IN LISTS reused_dir_targets)
if(TARGET ${target})

View File

@ -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,71 +14,41 @@ endif()
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/draganddrop")
find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Quick)
find_package(Qt6 COMPONENTS Qml)
find_package(Qt6 COMPONENTS Core Gui Quick Qml)
qt_add_executable(draganddrop
add_subdirectory("../shared" "shared")
qt_add_executable(draganddropexample
WIN32
MACOSX_BUNDLE
main.cpp
)
set_target_properties(draganddrop PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
qt_add_qml_module(draganddropexample
URI draganddrop
VERSION 1.0
QML_FILES
"draganddrop.qml"
"tiles/DragTile.qml"
"tiles/DropTile.qml"
"tiles/tiles.qml"
"views/Icon.qml"
"views/gridview.qml"
)
target_link_libraries(draganddrop PUBLIC
target_link_libraries(draganddropexample PUBLIC
Qt::Core
Qt::Gui
Qt::Qml
Qt::Quick
)
add_dependencies(draganddropexample draganddrop_shared)
# Resources:
set(draganddrop_resource_files
"draganddrop.qml"
"tiles/DragTile.qml"
"tiles/DropTile.qml"
"tiles/tiles.qml"
"views/Icon.qml"
"views/gridview.qml"
)
qt6_add_resources(draganddrop "draganddrop"
PREFIX
"/draganddrop"
FILES
${draganddrop_resource_files}
)
set(shared_resource_files
"../shared/Button.qml"
"../shared/CheckBox.qml"
"../shared/FlickrRssModel.qml"
"../shared/Label.qml"
"../shared/LauncherList.qml"
"../shared/SimpleLauncherDelegate.qml"
"../shared/Slider.qml"
"../shared/TabSet.qml"
"../shared/TextField.qml"
"../shared/images/back.png"
"../shared/images/checkmark.png"
"../shared/images/next.png"
"../shared/images/qt-logo.png"
"../shared/images/slider_handle.png"
"../shared/images/tab.png"
)
qt6_add_resources(draganddrop "shared"
PREFIX
"/shared"
BASE
"../shared"
FILES
${shared_resource_files}
)
install(TARGETS draganddrop
install(TARGETS draganddropexample
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
bundle_shared(draganddropexample)

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2017 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,8 +48,8 @@
**
****************************************************************************/
import QtQuick 2.0
import "../shared" as Examples
import QtQuick
import shared as Examples
Item {
height: 480

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2018 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 QtQml 2.14
import QtQuick 2.14
import QtQml.Models 2.14
import QtQml
import QtQuick
import QtQml.Models
GridView {
id: root