Alexander Dyagilev
Alexander Dyagilev

Reputation: 1325

QML: ListView delegate: items vs. MouseArea

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.

Upvotes: 2

Views: 1849

Answers (1)

Evgeny
Evgeny

Reputation: 4010

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.

Upvotes: 7

Related Questions