Quick question regarding MouseAreas and z: order



  • 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 :)



  • 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?



  • 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.


Log in to reply
 

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