Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
Hover event delivery

Conventionally, when the mouse moves, the user interface should show some feedback related to the items currently under the cursor. But Qt Quick supports animations, therefore it can also happen that some Items move into position underneath the cursor at times, and should therefore show feedback as if they were hovered; while other Items become un-hovered.

Actual mouse movement

Let's look at what happens when the mouse enters a window containing this QML, and then moves over the inner blue Rectangle:

import QtQuick
Rectangle {
color: outerMA.containsMouse ? "lightsteelblue" : "gray"
width: 100; height: 400
objectName: "outerRect"
MouseArea {
id: outerMA
objectName: "outerMA"
anchors.fill: parent
hoverEnabled: true
}
Rectangle {
color: "blue"
border.color: innerMA.containsMouse ? "white" : "transparent"
width: 80; height: 80; x: 10; y: 10
objectName: "innerRect"
MouseArea {
id: innerMA
objectName: "innerMA"
anchors.fill: parent
hoverEnabled: true
}
}
}

MouseArea is a bit old-fashioned, but it's instructive to see how events propagate to QQuickItems first, before we involve Pointer Handlers:

Hovering triggered from frame rendering

QQuickDeliveryAgentPrivate::flushFrameSynchronousEvents() gets called each time a frame is rendered. If animations are running, frames are being rendered. This function then calls QQuickDeliveryAgentPrivate::deliverHoverEvent().

{hover-due-to-animation.png} "Hovering triggered from frame rendering"

The above diagram needs to be redone to start with flushFrameSynchronousEvents().