Certain widgets will allow me to do:
self.widget.clicked.connect(on_click)
but doing:
self.widget.keyPressEvent.connect(on_key)
will fail saying that the object has no attribute 'connect'.
I know that sub-classing the widget and re-implementing the keyPressEvent
method will allow me to respond to the event. But how can I .connect()
to the keyboard event thereafter, or otherwise said, from a user context?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…