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)
|
||||
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"
|
||||
qt_add_qml_module(mouseareaexample
|
||||
URI mousearea
|
||||
VERSION 1.0
|
||||
QML_FILES
|
||||
"mousearea-wheel-example.qml"
|
||||
"mousearea.qml"
|
||||
)
|
||||
|
||||
qt6_add_resources(mousearea "mousearea"
|
||||
PREFIX
|
||||
"/mousearea"
|
||||
FILES
|
||||
${mousearea_resource_files}
|
||||
)
|
||||
|
||||
install(TARGETS mousearea
|
||||
install(TARGETS mouseareaexample
|
||||
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
BUNDLE 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/
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
|
@ -48,7 +48,7 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick
|
||||
|
||||
Rectangle {
|
||||
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/
|
||||
**
|
||||
** 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 {
|
||||
|
|
Loading…
Reference in New Issue