Make a widget transparent for mouse and keyboard events (propagate to the Window System Manager)
I have a transparent fullscreen widget and I want to propagate mouse and keyboard event to the system. i.e. use web-browser, file manager and etc.
Is there a way to do that?
Probably the Qt::WA_TransparentForMouseEvents "widget attribute":http://qt-project.org/doc/qt-4.8/qt.html#WidgetAttribute-enum should do the work:
w.setAttribute( Qt::WA_TransparentForMouseEvents );
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 the reply, but it works only within the bounds of the application. I think I should use Native API calls, i.e. simulate events for underlying windows, but it is not simple.
If yo have another idea, please write here :)
Could you explain the problem in greater detail...
You have your application running. The user gives some input, you detect this input in your application and want to explicitly pass it to another application or to the Window System Manager?
Yep. There is my app on top of the window stack (transparent) where I can paint on. But when none of any instruments for painting is selected then I want to pass any mouse and keyboard events to other apps. I mean, all the lines and other painted elements stay on screen, but user can interact with system as usually.
I need it in order to do video lessons capturing video from screen.
So, first off, you have created an application that when run shows some windows - palettes with instruments for painting. You say that your application does not occupy the whole screen but just some regions that provide the aforementioned tools. You want to draw on screen if a given instrument of your application is in use - for instance select or paint a region on the screen below which another application's window is positioned. You want the other applications to receive the mouse and keyboard events when no tool is selected.
So your problem should be how not to pass events to the other applications when the user clicks outside of all painting tools palettes ' windows during the time a tool is active. Isn't it this the actual question?
Forget everything else and see "this":http://stackoverflow.com/a/4930925/1082289.
Although it is not cross-platform (Windows specific) but it works like charm! : )
I hope you like it.
Was this ever solved for Linux?
This worked for me: