选择哪个信号连接到插槽
choose which signal is connected to the slot
当存在具有相同名称但发出不同参数的信号时如何使用特定信号。
buttonGroup = QButtonGroup()
buttonGroup.buttonClicked.connect( self.onButtonClicked )
@Slot(int)
def onButtonClicked(self, buttonIndex):
self.currentFile = self.files[buttonIndex]
默认情况下,上面的代码似乎选择了第二个信号(发出 PySide.QtGui.QPushButton 元素)
Traceback (most recent call last):
File "/home/riless/main.py", line 154, in onButtonClicked
self.currentFile = self.files[buttonIndex]
TypeError: list indices must be integers, not PySide.QtGui.QPushButton
我只需要更改这一行:
buttonGroup.buttonClicked.connect( self.onButtonClicked )
这个:
buttonGroup.buttonClicked[int].connect( self.onButtonClicked )
当存在具有相同名称但发出不同参数的信号时如何使用特定信号。
buttonGroup = QButtonGroup()
buttonGroup.buttonClicked.connect( self.onButtonClicked )
@Slot(int)
def onButtonClicked(self, buttonIndex):
self.currentFile = self.files[buttonIndex]
默认情况下,上面的代码似乎选择了第二个信号(发出 PySide.QtGui.QPushButton 元素)
Traceback (most recent call last):
File "/home/riless/main.py", line 154, in onButtonClicked
self.currentFile = self.files[buttonIndex]
TypeError: list indices must be integers, not PySide.QtGui.QPushButton
我只需要更改这一行:
buttonGroup.buttonClicked.connect( self.onButtonClicked )
这个:
buttonGroup.buttonClicked[int].connect( self.onButtonClicked )