diff options
author | Oliver Eftevaag <oliver.eftevaag@qt.io> | 2021-11-08 15:09:04 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-11-12 09:40:51 +0000 |
commit | 829acdc72d2aa1034c7b88b3d2bd7a8f2efaf0a8 (patch) | |
tree | cd001411bfe8a0e996887bb9222888ec5190a5a8 /examples | |
parent | 025894f802fabc479d308eb32635c9703046d239 (diff) |
MouseArea example: use qt_add_qml_module() and update a signal handler
Thing patch updates the CMakeLists.txt file to use qt_add_qml_module()
instead of qt6_add_resource().
Additionally, it changes a signal handler, which was previously a plain
statement, into a js function, which is the preferred way to write signal
handlers.
Task-number: QTBUG-98130
Change-Id: I1b08dcd3eae370d78587aa3d37d9456437b54b42
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit 28bfd773cac84d228df9e6bdcc9bed84d79935c5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/quick/mousearea/CMakeLists.txt | 35 | ||||
-rw-r--r-- | examples/quick/mousearea/mousearea-wheel-example.qml | 4 | ||||
-rw-r--r-- | examples/quick/mousearea/mousearea.qml | 6 |
3 files changed, 15 insertions, 30 deletions
diff --git a/examples/quick/mousearea/CMakeLists.txt b/examples/quick/mousearea/CMakeLists.txt index 190e34b172..ea635462be 100644 --- a/examples/quick/mousearea/CMakeLists.txt +++ b/examples/quick/mousearea/CMakeLists.txt @@ -1,13 +1,9 @@ -# Generated from mousearea.pro. - cmake_minimum_required(VERSION 3.16) project(mousearea LANGUAGES CXX) 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,19 +11,12 @@ endif() set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/mousearea") -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(mousearea +qt_add_executable(mouseareaexample WIN32 MACOSX_BUNDLE main.cpp ) -set_target_properties(mousearea PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(mousearea PUBLIC +target_link_libraries(mouseareaexample PUBLIC Qt::Core Qt::Gui Qt::Qml @@ -36,19 +25,15 @@ target_link_libraries(mousearea PUBLIC # Resources: -set(mousearea_resource_files - "mousearea-wheel-example.qml" - "mousearea.qml" -) - -qt6_add_resources(mousearea "mousearea" - PREFIX - "/mousearea" - FILES - ${mousearea_resource_files} +qt_add_qml_module(mouseareaexample + URI mousearea + VERSION 1.0 + QML_FILES + "mousearea-wheel-example.qml" + "mousearea.qml" ) -install(TARGETS mousearea +install(TARGETS mouseareaexample RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" diff --git a/examples/quick/mousearea/mousearea-wheel-example.qml b/examples/quick/mousearea/mousearea-wheel-example.qml index 5e8fba3ac3..77893fd57c 100644 --- a/examples/quick/mousearea/mousearea-wheel-example.qml +++ b/examples/quick/mousearea/mousearea-wheel-example.qml @@ -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,7 +48,7 @@ ** ****************************************************************************/ -import QtQuick 2.0 +import QtQuick Rectangle { height: 700 diff --git a/examples/quick/mousearea/mousearea.qml b/examples/quick/mousearea/mousearea.qml index ff792f952d..677b5f384d 100644 --- a/examples/quick/mousearea/mousearea.qml +++ b/examples/quick/mousearea/mousearea.qml @@ -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,7 +48,7 @@ ** ****************************************************************************/ -import QtQuick 2.4 +import QtQuick Rectangle { id: box @@ -177,7 +177,7 @@ Rectangle { id: info anchors.bottom: btn.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20 - onTextChanged: console.log(text) + onTextChanged: function(text) { console.log(text) } } Text { |