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 Pick-to: 6.2 Change-Id: I1b08dcd3eae370d78587aa3d37d9456437b54b42 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
parent
aa4897e017
commit
28bfd773ca
|
@ -1,13 +1,9 @@
|
||||||
# Generated from mousearea.pro.
|
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
project(mousearea LANGUAGES CXX)
|
project(mousearea LANGUAGES CXX)
|
||||||
|
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
|
||||||
set(CMAKE_AUTOMOC ON)
|
set(CMAKE_AUTOMOC ON)
|
||||||
set(CMAKE_AUTORCC ON)
|
|
||||||
set(CMAKE_AUTOUIC ON)
|
|
||||||
|
|
||||||
if(NOT DEFINED INSTALL_EXAMPLESDIR)
|
if(NOT DEFINED INSTALL_EXAMPLESDIR)
|
||||||
set(INSTALL_EXAMPLESDIR "examples")
|
set(INSTALL_EXAMPLESDIR "examples")
|
||||||
|
@ -15,19 +11,12 @@ endif()
|
||||||
|
|
||||||
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/mousearea")
|
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/mousearea")
|
||||||
|
|
||||||
find_package(Qt6 COMPONENTS Core)
|
find_package(Qt6 COMPONENTS Core Gui Quick Qml)
|
||||||
find_package(Qt6 COMPONENTS Gui)
|
|
||||||
find_package(Qt6 COMPONENTS Quick)
|
|
||||||
find_package(Qt6 COMPONENTS Qml)
|
|
||||||
|
|
||||||
qt_add_executable(mousearea
|
qt_add_executable(mouseareaexample WIN32 MACOSX_BUNDLE
|
||||||
main.cpp
|
main.cpp
|
||||||
)
|
)
|
||||||
set_target_properties(mousearea PROPERTIES
|
target_link_libraries(mouseareaexample PUBLIC
|
||||||
WIN32_EXECUTABLE TRUE
|
|
||||||
MACOSX_BUNDLE TRUE
|
|
||||||
)
|
|
||||||
target_link_libraries(mousearea PUBLIC
|
|
||||||
Qt::Core
|
Qt::Core
|
||||||
Qt::Gui
|
Qt::Gui
|
||||||
Qt::Qml
|
Qt::Qml
|
||||||
|
@ -36,19 +25,15 @@ target_link_libraries(mousearea PUBLIC
|
||||||
|
|
||||||
|
|
||||||
# Resources:
|
# Resources:
|
||||||
set(mousearea_resource_files
|
qt_add_qml_module(mouseareaexample
|
||||||
"mousearea-wheel-example.qml"
|
URI mousearea
|
||||||
"mousearea.qml"
|
VERSION 1.0
|
||||||
|
QML_FILES
|
||||||
|
"mousearea-wheel-example.qml"
|
||||||
|
"mousearea.qml"
|
||||||
)
|
)
|
||||||
|
|
||||||
qt6_add_resources(mousearea "mousearea"
|
install(TARGETS mouseareaexample
|
||||||
PREFIX
|
|
||||||
"/mousearea"
|
|
||||||
FILES
|
|
||||||
${mousearea_resource_files}
|
|
||||||
)
|
|
||||||
|
|
||||||
install(TARGETS mousearea
|
|
||||||
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
|
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||||
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
|
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||||
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
|
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2017 The Qt Company Ltd.
|
** Copyright (C) 2021 The Qt Company Ltd.
|
||||||
** Contact: https://www.qt.io/licensing/
|
** Contact: https://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
** This file is part of the examples of the Qt Toolkit.
|
** This file is part of the examples of the Qt Toolkit.
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
import QtQuick 2.0
|
import QtQuick
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
height: 700
|
height: 700
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2017 The Qt Company Ltd.
|
** Copyright (C) 2021 The Qt Company Ltd.
|
||||||
** Contact: https://www.qt.io/licensing/
|
** Contact: https://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
** This file is part of the examples of the Qt Toolkit.
|
** This file is part of the examples of the Qt Toolkit.
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
import QtQuick 2.4
|
import QtQuick
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: box
|
id: box
|
||||||
|
@ -177,7 +177,7 @@ Rectangle {
|
||||||
id: info
|
id: info
|
||||||
anchors.bottom: btn.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20
|
anchors.bottom: btn.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20
|
||||||
|
|
||||||
onTextChanged: console.log(text)
|
onTextChanged: function(text) { console.log(text) }
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
|
|
Loading…
Reference in New Issue