【发布时间】:2017-12-14 14:29:57
【问题描述】:
我正在使用带有 2 个重载的信号
buttonClicked = pyqtSignal([int],[str])
我只想用一个插槽连接一个重载(int)。每当我调用发出另一个重载(str)时,我都不希望发生任何事情。如何做到这一点?
class Example(QWidget):
buttonClicked = pyqtSignal([int],[str])
def __init__(self):
super().__init__()
self.init_ui()
def init_ui(self):
self.btn = QPushButton('Button',self)
self.btn.clicked.connect(self.doAction)
self.make_conn()
self.setWindowTitle('Yo')
self.show()
def make_conn(self):
self.buttonClicked.connect(self.showDialog) #How to make specific connection here . Using self.buttonClicked[int].connect(self.showDialog) doesnt work.
def showDialog(self):
print('here')
def doAction(self):
self.buttonClicked.emit('soru') #should NOT call showDialog
self.buttonClicked.emit(23) #should call showDialog
【问题讨论】:
标签: python python-3.x pyqt pyqt5 signals-slots