这是一些简单的QML代码,其中包含 Button
和 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
接受鼠标事件?
1 回答
试试这个,如果我理解你:
但我建议你用常用的方式来显示按钮弹出窗口 . 使用
Button.menu
显示下拉菜单按钮 .