Translucent widget does not let events through on Linux
I have an application with a background widget (which displays clickable items) and an overlaying widget on top of it. This overlaying widget has a translucent background (with attribute
WA_TranslucentBackground) in order to be able to see the background widget through it, and it also has the
Qt::Toolflag so that it always stays on top. The overlaying widget has a few children with buttons and pictures (which thus create non-transparent clickable parts).
On Windows, clicking on a fully transparent part of the overlaying widget works as expected, i.e. the background widget receives the mouse click event.
On Linux (Debian Stretch, I couldn't not test on any other distro) however, clicking on a transparent part of the overlaying widget does not work as expected. The background widget never receives the mouse event ; the overlaying widget (or on of its children) gets the event instead of letting it go through.
I have looked for other flags and attributes which would explain that, but with to luck. I have tested with the
WA_TransparentForMouseEventsattribute on the overlaying widget: this attribute works as expected (the background widget gets the events and the overlaying widget does not), but I still need to be able to click on the opaque parts of the overlaying widget, so this attribute is not a solution.
Has anybody any clue why this behaviour is different on Windows and Linux, and is there a way to fix that?
Report it as a bug in the Qt bugtracker. Behaviour should be either consistent on all platforms, or the documentation should explicitly mention differences.
Regarding your problem: try reimplementing mouse events (http://doc.qt.io/qt-5/qwidget.html#mousePressEvent et al) and setting
event->setAccepted(false). This will propagate the events further (and by checking event coordinates you can selectively block/ unblock regions of the widget).
Thanks for your reply. I have reported it as a bug.
As for your solution, I am trying it right now.