1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| # -*- coding: utf-8 -*- # @Time : 2020/12/11 17:03 # @Author : lockcy
from PyQt5.QtCore import QObject, pyqtSignal
class CustSignal(QObject): signal1 = pyqtSignal() signal2 = pyqtSignal(int) signal3 = pyqtSignal(int, str) signal4 = pyqtSignal(list) signal5 = pyqtSignal(dict) signal6 = pyqtSignal([int,str], [str])
def __init__(self, parent=None): super(CustSignal, self).__init__(parent) self.signal1.connect(self.signalCall1) self.signal2.connect(self.signalCall2) self.signal3.connect(self.signalCall3) self.signal4.connect(self.signalCall4) self.signal5.connect(self.signalCall5) self.signal6[int, str].connect(self.signalCall6) self.signal6[str].connect(self.signalCall6Overload)
self.signal1.emit() self.signal2.emit(1) self.signal3.emit(1, "text") self.signal4.emit([1, 2, 3, 4]) self.signal5.emit({"username": "aa", "password": "bb"}) self.signal6[int, str].emit(1, "text") self.signal6[str].emit("text")
def signalCall1(self): print("signal1 emit") def signalCall2(self, val): print("signal2 emit,value:", val) def signalCall3(self, val, text): print("signal3 emit,value:", val, text) def signalCall4(self, val): print("signal4 emit,value:", val) def signalCall5(self, val): print("signal5 emit, value:", val) def signalCall6(self, val, text): print("signal6 emit, value:", val, text) def signalCall6Overload(self, val): print("signal6 overload emit,value:", val)
if __name__ == '__main__': custSignal = CustSignal()
|