Ability to process mouse events in a mask
-
Hi all.
I am usingQWidget::setMask
which is a very powerful and neat feature.
What I am trying to make work is to be able to intercept mouse events outside the mask in the same widget.
For instance I want to be able to delegate the event to the widget if the user presses a certain keystroke inside this black hole representing the background behind this window, for exampleCtrl+Shift
.
Is this feasible? Because,QMainWindow::event
isn't called at all inside it.
I have another related question, but I will ask it later, maybe the solution is related too.
Thanks. -
Actually my second question, is when using:
window.setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); window.setAttribute(Qt::WA_TranslucentBackground);
Mouse events are delegated to background OS when the user clicks the transparent areas, is there any ways to delegate these events to the
QWidget
and stop them from reaching the background when certain conditions are met? -
Maybe of interest ?
Qt::WA_NoMousePropagation 73 Prohibits mouse events from being propagated to the widget's parent. This attribute is disabled by default.
Qt::WA_TransparentForMouseEvents 51 When enabled, this attribute disables the delivery of mouse events to the widget and its children. Mouse events are delivered to other widgets as if the widget and its children were not present in the widget hierarchy; mouse clicks and other events effectively "pass through" them. This attribute is disabled by default.
-
Thanks for your reply.
Well I am asking this question here after a long search over similar issues/topics I found on the net, and after trying a different combinations/solutions which aren't solving my problem fully.
AFAIK,Qt::WA_*
have effect on widgets not on windows (enums inQt::WidgetAttribute
).
The main problem is there a possible way to dismiss events and delegate them to background system widgets while still knowing about them?
For example, usingsetWindowFlag(Qt::WindowTransparentForInput, true)
enables clickthrough but:- event processing is lost completely in the
QMainWindow
so theQWidget::event
isn't called at all (which is a problem). - when using
setWindowFlag(Qt::WindowTransparentForInput, true)
to disable clickthrough, the event system becomes somehow broken.
My main problem summed up, I want to be able to enable/disable clickthrough correctly, while be able to query events even when clickthrough is enabled in a cross-platform way.
If you want some real life software using this behavior, check Rainmeter (windows only widget app). So basically I already know that this is feasible with windows API, but I am looking for a crossplatform solution if available.
Any ideas? - event processing is lost completely in the
-