import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick 2.13
import QtQuick.Controls 1.4
import QtQuick.Dialogs 1.3
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
Rectangle {
id: btn
anchors.fill: parent
color: 'red'
// 鼠标区域
MouseArea {
anchors.fill: parent
onClicked: {
console.log('red')
}
}
Rectangle {
width: parent.width / 2
height: parent.height / 2
color: 'blue'
// 鼠标区域与上面的父元素鼠标区域重叠
MouseArea {
anchors.fill: parent
propagateComposedEvents: true // 鼠标穿透
onClicked: {
mouse.accepted = false // 传递到下面的父元素
console.log('blue')
}
}
}
}
}
Qml 工作记录:MouseArea区域重叠,鼠标穿透示例
最新推荐文章于 2023-05-01 10:02:58 发布