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 the entered 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 MouseAreas, and he wants the smaller one (which is has higher z) to eat up events when the events fall within both. I want both overlapping MouseAreas to handle events that fall within both.



  • Have you found the answer?



  • @jalomic: No, sorry, I haven't.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.