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:
QtWidgets.QWidget.setWindowFlags(QtCore.Qt.WindowTransparentForInput)
QtWidgets.QWidget.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents)
QtWidgets.QWidget.setMask(QtGui.QRegion(self.geometry()))
mousePressEvent
and ignoring the eventYou 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)