I'm building an overlay to display OBS stream stats over an full screen applications.
I've managed to achieve the visual part of it by setting the windows flags to: WindowStaysOnTopHint | FramelessWindowHint X11BypassWindowManagerHint)
The issue is that this window responds to the mouse (changes cursor to system one when hovered) and blocks the click actions. I found that WA_TransparentForMouseEvents
and WA_TranslucentBackground
will help, but it does not.
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtCore import Qt
app = QApplication([])
window = QWidget()
window.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint )#| Qt.X11BypassWindowManagerHint)
window.setAttribute(Qt.WA_TransparentForMouseEvents,True)
window.setAttribute(Qt.WA_TranslucentBackground,True)
window.show()
app.exec()
How can I make QtWindow to be transparent for the mouse and other events. In other works to act as a proper overlay.
CodePudding user response:
The flag needed to be set is:
Qt::WindowTransparentForInput
Informs the window system that this window is used only for output (displaying something) and does not take input. Therefore input events should pass through as if it wasn't there.