Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Qt Quick: How to handle hover-type events in MouseArea, yet let lower-z MouseAreas handle them too?
Forum Update on Monday, May 27th 2025

Qt Quick: How to handle hover-type events in MouseArea, yet let lower-z MouseAreas handle them too?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
event-handlingmouseevent
4 Posts 3 Posters 1.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Stefan Monov76S Offline
    Stefan Monov76S Offline
    Stefan Monov76
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jalomic
      wrote on last edited by
      #2

      Have you found the answer?

      Stefan Monov76S 1 Reply Last reply
      0
      • J jalomic

        Have you found the answer?

        Stefan Monov76S Offline
        Stefan Monov76S Offline
        Stefan Monov76
        wrote on last edited by
        #3

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

        A 1 Reply Last reply
        0
        • Stefan Monov76S Stefan Monov76

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

          A Offline
          A Offline
          AliGh
          wrote on last edited by
          #4

          @Stefan-Monov76 Have you found the answer?

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved