2
votes

I have the following code:

ListView {
    delegate: MyDelegate {
        MouseArea {
            anchors.fill: parent
            /*some other stuff*/
        }
    }
}

The problem is that MyDelegate contains checkboxes and MouseArea "steals" mouse events from them. They do not react on mouse events at all, i.e. do not work as expected.

I know about propagateComposedEvents property of MouseArea...but I'll have to implement all of its mouse events (clicked, pressed, released,...) and check whether the mouse cursor is in the checkbox or not to set mouse.accepted property accordingly.

This is how I understood all of these currently. Is there any easier way, i.e. a way to be able to process all of the mouse events for areas that does not handle mouse events explicitly? For instance static text, progress bars, etc.

1
Did you try z-index?Evgeny
How could I use it in my case? I mean MouseArea is a child of MyDelegate (am I right?). In this case there is no way to change Z order. Isn't it?Alexander Dyagilev
You can set z property for checkbox higher then for the mouseareaEvgeny
I've set z to 100 for checkboxes - did not help.Alexander Dyagilev
Haha. Setting Z property of MouseArea to -1 works just as needed!. Thanks. Please post as an answer. I'll mark it.Alexander Dyagilev

1 Answers

7
votes

You can apply negative values to the z property of the MouseArea.

From the documentation:

Items with a higher stacking value are drawn on top of siblings with a lower stacking order. Items with the same stacking value are drawn bottom up in the order they appear. Items with a negative stacking value are drawn under their parent's content.