···
from PyQt5.QtCore import *
class NNSignal(QObject):
# 定义一个信号
signal1 = pyqtSignal()
# 发送3个参数的信号
signal2 = pyqtSignal(int)
signal3 = pyqtSignal()
def __init__(self):
super().__init__()
self.signal1.connect(self.signal_call1)
self.signal1.connect(self.signal_call11)
self.signal2.connect(self.signal1)
self.signal3.connect(self.signal_call1)
self.signal1.emit()
self.signal2.emit(10) # signal1关联的是信号1,所以触发的还是信号1
self.signal3.emit()
# 解除关联
self.signal1.disconnect(self.signal_call1)
self.signal1.disconnect(self.signal_call11)
self.signal2.disconnect(self.signal1)
self.signal1.connect(self.signal_call1)
self.signal2.connect(self.signal_call2)
self.signal1.emit()
self.signal2.emit(100)
def signal_call1(self):
print("signal1 emit")
def signal_call11(self):
print("signal1 call 11")
def signal_call2(self, val):
print("signal2 emit, value=", val)
if name == 'main':
NNSignal()
标签:signal,self,signal2,signal1,connect,信号,emit
From: https://www.cnblogs.com/jackchen28/p/18238338