qml mousearea overlab 在 hoverenable 模式下不起作用

qml mousearea overlab not work in hoverenable mode

我的问题是 mouseArea 不传递悬停事件。我该如何解决这个问题?换句话说,我想在 example.thanks.

中一起打印 1 和 2
Window {
visible: true
width: 640
height: 480
MouseArea{
    anchors.fill: parent
    hoverEnabled: true
    preventStealing: true
    propagateComposedEvents: true
    onPositionChanged: console.log("1")
}
MouseArea{
    anchors.fill: parent
    hoverEnabled: true
    preventStealing: true
    propagateComposedEvents: true
    onPositionChanged: {
        console.log("2")
    }
}

propagateComposedEvents 仅适用于 clickeddoubleClickedpressAndHold 事件:

This property holds whether composed mouse events will automatically propagate to other MouseAreas that overlap with this MouseArea but are lower in the visual stacking order. By default, this property is false.

MouseArea contains several composed events: clicked, doubleClicked and pressAndHold. These are composed of basic mouse events, like pressed, and can be propagated differently in comparison to basic events.

您可以定义自己的自定义 QQuickItem,在 MouseArea 上安装事件过滤器,或者只是手动通知其他 MouseArea 悬停事件。