79608566

Date: 2025-05-06 11:14:19
Score: 1
Natty:
Report link

Per @musicamante's advice, i put an event filter on a subclass of `QMainWindow` and now the keypress event is being read anywhere.

class MainWindow(QMainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        app.installEventFilter(self) #keyboard control

    def eventFilter(self, obj, ev):
        if (ev.type() == QtCore.QEvent.Type.KeyPress):
            <<Stuff>>
        return super(MainWindow, self).eventFilter(obj, ev)

Reasons:
  • Has code block (-0.5):
  • User mentioned (1): @musicamante's
  • Self-answer (0.5):
Posted by: Ghost