本文介绍了pyside连接错误“RuntimeError:无法连接信号clicked()";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
from PySide.QtCore import *
from PySide.QtGui import *
import sys
import stackwid
class Dialog(QDialog,stackwid.Ui_Dialog):
def __init__(self,parent = None):
super(Dialog,self).__init__(parent)
self.setupUi(self)
self.camButton.clicked.connect(self.set())
def set(self):
self.stackedWidget.setCurrentIndex(1)
app = QApplication(sys.argv)
form = Dialog()
form.show()
app.exec_()
我想将 camButton(PushButton) 发出的 clicked() 信号连接到插槽,这是一个函数 set().这只是不运行.
I wanted to connect clicked() signal emitted by camButton(PushButton) to slot which is a function set().This just does not run .
RuntimeError: Failed to connect signal clicked()
推荐答案
您没有将信号连接到 set()
函数,而是连接到它的返回值.您只需要删除括号,然后它应该可以工作:
You don't connect the signal to your set()
-function, but to it's return value. You just need to remove the parenthesis, then it should work:
self.camButton.clicked.connect(self.set)
这篇关于pyside连接错误“RuntimeError:无法连接信号clicked()";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!