[SOLVED] Prevent all mouse events from propagating to items below
-
Hello!
Just getting properly into Qt Quick and QML now, the initial learning curve pain is subsiding. Alas, I have a question I thought I'd find an answer to with the power of Google, but couldn't find exactly what I was looking for.
So: in a Qt Quick Components desktop app I have an overlay that I'm using with the rather nice "Progress Spinner":http://qt-project.org/wiki/QML_Progress_Spinner to indicate when the application is off doing stuff.
When the app is off doing stuff, the overlay is shown over the whole window and I don't want any of the controls underneath to respond to any mouse events. At the moment, I've managed to inhibit button clicks but the elements underneath still respond to hover events (the buttons still show tooltips, the table view still highlights its header). How can I blanket prevent all mouse events from reaching the controls underneath?
The code:
@MouseArea {
enabled: true
width: parent.width
height: parent.height
z: parent.z
propagateComposedEvents: false
hoverEnabled: false
preventStealing: true
}@ -
Hello,
the problem is you set hoverEnabled to false so your MouseArea doesn't catch this event so the event bubble down to other elements with mouse handling. I don't know if it's a bug. But here a working solution.
ApplicationWindow { visible: true width: 640 height: 480 title: qsTr("Hello World") Rectangle { anchors.fill: parent color: 'red' Button { width: 200 height: 100 text: "test" onClicked: { overlay.visible = true } } } Rectangle { id: overlay z: 2 color: "#aa000000" anchors.fill: parent MouseArea { anchors.fill: parent propagateComposedEvents: false hoverEnabled: true preventStealing: true onClicked: { overlay.visible = false } } } }
-
I like it when a solution is that simple. Thanks a lot!
-
Thank you, I've just run into this problem!