PyQt5基础学习-pyqtSignal(str, int, int)(传递多个参数)
在构造信号的时候,构造多个参数的信号,构造槽函数时,允许接收多个输入的函数
CustomMultiSignal.py
""" 自定义信号 pyqtSignal() """ from PyQt5.QtCore import * class MyTypeSignal(QObject): #定义一个信号 sendmsg = pyqtSignal(object) #定义多个参数信号 sendmsg1 = pyqtSignal(str, int, int) #触发信号 def run(self): self.sendmsg.emit("Hello PyQt5") def run1(self): self.sendmsg1.emit("hello", 3, 4) #构造槽函数 class MySlot(QObject): def get(self, msg): print("信息:" + msg) def get1(self, msg, a, b): print(msg) print(a + b) if __name__ == "__main__": send = MyTypeSignal() slot = MySlot() send.sendmsg.connect(slot.get) send.sendmsg1.connect(slot.get1) send.run() send.run1() #断开连接 send.sendmsg.disconnect(slot.get) send.run()
每天更新pyQt5内容