这是一些包含 aButton
和 a 的简单 QML 代码MouseArea
。我想要Button
检测鼠标左键和右键。
Rectangle {
anchors.fill:parent;
width: 1302
height: 638
Button {
id: button1
x: 378
y: 332
width: 194
height: 66
text: qsTr("Button")
}
MouseArea {
id: mouseArea1
x: 368
y: 306
width: 226
height: 108
acceptedButtons: Qt.RightButton
propagateComposedEvents: true
onClicked: {
console.log("Click")
mouse.accepted = false
}
}
}
由于MouseArea
位于 顶部Button
,如何强制Button
接受鼠标事件?