Qt Quick: How to handle hover-type events in MouseArea, yet let lower-z MouseAreas handle them too?
-
If, on my MouseArea, I've enabled the property
hoverEnabled
, I'm notified of theentered
signal, even if no mouse button is held at that time (just as I want).But then a lower-z MouseArea will not receive positionChanged events on the first MouseArea's space, since they're eaten up by the first MouseArea.
The Qt docs on
positionChanged
specifically say this:When handling this signal, changing the accepted property of the mouse parameter has no effect.
Example code:
Item { width: 100 height: 100 MouseArea { anchors.fill: parent hoverEnabled: true onPositionChanged: { console.log("MouseArea 1"); } } MouseArea { anchors.fill: parent hoverEnabled: true onEntered: { console.log("MouseArea 2"); } } }
"MouseArea 1" is never printed. I want both strings to be printed.
Is there a way to do it?
Related question note: This question is very similar but the asker there has 2 differently-sized overlapping
MouseArea
s, and he wants the smaller one (which is has higher z) to eat up events when the events fall within both. I want both overlappingMouseArea
s to handle events that fall within both. -
@Stefan-Monov76 Have you found the answer?