PyQt
PyQt
1. Event-loop
event queue
event loop
event handler

2. Signal / Slot
signal
Event loop manager
slot
action
dispatcher
store / view
callback = [1] pointer to function, [2] compare to signal-slot, callback may type-mismatch
event occur -> signal emit -> slot response

2.1 widget.signal
button.clicked.connect(slot_function) // widget.signal.connect(slot_function)
2.2 customized signal
class Example(QMainWindow):
closeApp = pyqtSignal()
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.closeApp.connect(self.close) // signal.connect.(slot_function) // without widget
...
def mousePressEvent(self, event):
self.closeApp.emit() // signal.emit
Last updated
Was this helpful?