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. Quick question regarding MouseAreas and z: order

Quick question regarding MouseAreas and z: order

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.3k 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.
  • V Offline
    V Offline
    VRHans
    wrote on last edited by
    #1

    I was under the impression that as Qt encounters Qml, at the sibling level, z order increases.

    Therefore, if I do this:

    Rectangle {
    	MouseArea {
    		id: Mouse1
    	}
        
    	ListView {
    		delegate: Rectangle {
    			MouseArea {
    				id: Mouse2
    			}
    		}
    	}
    }
    

    I would expect that Mouse2 would receive mouse events before Mouse1. What I appear to experience is that Mouse1 gets the mouse events. I can fix this by giving the delegate a z order of 1, but while that solves the issue - I don't understand why it's necessary.

    Is this related in some fashion to how Qt implements the listview and elements under the hood or am I just misreading something?

    Thanks :)

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Schluchti
      wrote on last edited by
      #2

      It's just a wild guess, but as you are creating two MouseAreas that are at the same hierachy level (siblings), I could imagine that Qt processes the events "top-to-bottom", so that the first MouseArea wins. When you change the z property you kind of overlap the other MouseArea, so that now the other MouseArea catches the events.

      But again, that's just a wild guess. ;-)
      Is there something specific you want to accomplish that you would need two sibling MouseAreas?

      Want to read more about Qt?

      https://gympulsr.com/blog/qt/

      Latest Article: https://gympulsr.com/blog/qt/2017/06/14/ios-background-music-qt.html

      1 Reply Last reply
      0
      • V Offline
        V Offline
        VRHans
        wrote on last edited by
        #3

        They shouldn't be at the same level in the hierarchy though (as far as I can tell.)

        The ListView is a sibling or child (depending upon the code internal to Qt) of the base Rectangle, and the delegate items should definitely be children of the list view - that should make them higher on the z order stacking list than the Rect containing Mouse1.

        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