我有这样的代码:
import QtQuick 2.0
import QtQuick.Window 2.0
Window {
visible: true
width: 500
height: 500
GridView {
id: grid
anchors.fill: parent
cellWidth: 30
cellHeight: 30
model: 120
delegate: Rectangle {
width: grid.cellWidth
height: grid.cellHeight
color: "grey"
}
MouseArea {
anchors.fill: parent
onPressed: console.info(">> PRESSED triggered")
onMouseXChanged: console.info(">> " + mouseX)
onReleased: console.info(">> RELEASED triggered")
preventStealing: true
propagateComposedEvents: true
}
}
}
当我按下鼠标按钮并严格沿X轴移动时,MouseArea
触发器中的所有信号。但是,当鼠标也向上或向下移动时,沿Y轴时,onMouseXChanged
和onReleased
信号不会触发。GridView
似乎拦截MouseArea
的信号,从MouseArea
窃取它们。我该如何使它们一起工作: GridView
带有 MouseArea
内部?
将MouseArea
中的true
设置为防止播放。
此属性是否可以从此鼠标中偷走鼠标事件。
如果将Mousearea放置在过滤儿童鼠标事件的项目中,例如可抛光的事件,则如果父母项目识别出手势,例如轻弹的手势。如果预防播放设置为True,则没有任何项目会窃取鼠标事件。