QML中MouseArea叠加的情况处理方式:
今天在学习QML的过程中,发现一个问题,因为是新手,正在学习,所以难免会碰到各种各样的问题。有些难免很奇葩。先上个代码:
import QtQuick 2.8
import QtQuick.Window 2.2
Window {
visible: true
width:root.width
height: root.height
title: qsTr("Hello World")//只有加了qsTr才能被国际化的翻译
Image {
id: root
source: "images/background.png"
width: 960
height: 640
}
Image {
id: pinwheel
source: "images/pinwheel.png"
anchors.centerIn: parent
Behavior on rotation {
NumberAnimation{
duration:250
}
}
MouseArea{
anchors.fill: parent
onClicked: {
pinwheel.rotation-=360
}
}
}
Text {
id: textCenter
text: qsTr("Hello World")
anchors.centerIn: parent
}
MouseArea{
anchors.fill: root
onClicked:{
pinwheel.rotation+=360
}
}
}
这段代码的作用就是显示类似