pythonpyside2qmouseevent

PySide2 pass mouse events to system


I'm using a QDialog with transparency enabled to select a region of the screen for a screen capture tool. When the user clicks inside the transparent widget I want to ignore the mouse event so that the system handles it. Is this possible?

I'm trying to achieve this on Linux.

Some things I have tried with no success:


Solution

  • You have to use the flag X11BypassWindowManagerHint so that you omit the window manager next to WindowTransparentForInput so that the system knows that it only has to show the window but does not notify you about the inputs.

    w.setWindowFlags(w.windowFlags() | 
        QtCore.Qt.WindowTransparentForInput | 
        QtCore.Qt.X11BypassWindowManagerHint)