I need a window with the following properties:
- It should be always on top.
- Able to receive mouse events (movements and clicks).
- Does not steal keyboard focus when clicked on.
Since a solution through Qt does not exist, I know that we have to use the Win32 API for the Windows platform. And I have to use this call:
SetWindowLongPtr(hwnd, GWL_EXSTYLE, WS_EX_NOACTIVATE)
But how can I implement this in my Python code?
Nicely explained here: qt_forum.
My code:
class Ui_self(QWidget):
def __init__(self):
super().__init__()
self.resize(150, 200)
self.secret_button = QtWidgets.QPushButton(self)
self.secret_button.setText("# tag")
elf.setWindowFlags(Qt.WindowStaysOnTopHint)
elf.setWindowFlags(Qt.FramelessWindowHint)
self.secret_button.setFocusPolicy(Qt.NoFocus)
self.setFocusPolicy(Qt.NoFocus)
self.setAttribute(Qt.WA_ShowWithoutActivating)
if __name__ == "__main__":
app = QApplication(sys.argv)
ex = Ui_self()
ex.show()
sys.exit(app.exec())