Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python TypeError:PySide.QtCore.QObject.connect():参数不足_Python_Qt_Pyside_Qthread_Qt Signals - Fatal编程技术网

Python TypeError:PySide.QtCore.QObject.connect():参数不足

Python TypeError:PySide.QtCore.QObject.connect():参数不足,python,qt,pyside,qthread,qt-signals,Python,Qt,Pyside,Qthread,Qt Signals,我正试图从QThread发出一个信号来更新progressBar class Signal(QtCore.QObject): this = QtCore.Signal(int) class Load(QtCore.QThread): def __init__(self, parent): QtCore.QThread.__init__(self, parent) self.parent = parent s

我正试图从
QThread
发出一个信号来更新
progressBar

class Signal(QtCore.QObject):
    this = QtCore.Signal(int)

class Load(QtCore.QThread):
    def __init__(self, parent):
            QtCore.QThread.__init__(self, parent)
            self.parent = parent
            self.onProgress = Signal()

    def run(self):
        '''
        '''
        stacks = []
        count = 100
        for i in range(count):
            # do something ... 
            self.onProgress.this.emit(count)
我在主窗口中如何称呼它

    def __init__(self ... ):
            ...
            self.Thread = Load(self)
            self.Thread.onProgress.connect(self.onProgress)
            self.Thread.start()

    @QtCore.Slot(int)
    def onProgress(self, int):
        self.ui.progressBar.setValue(self.ui.progressBar.value() + (90/int))
但我总是犯这个错误

TypeError: PySide.QtCore.QObject.connect(): not enough arguments

您正在连接到
onProgress
,它是
Signal
类的一个实例(在本文中是一个误导性的名称)。您希望连接到onProgress上的
。这是实际的信号对象:

self.Thread.onProgress.this.connect(self.onProgress)
或者将
onProgress
分配给信号本身:

self.onProgress = Signal().this

我不确定你想用
这个
名字做什么,但我认为它不起作用。你看过吗?它有一个很好的描述。我想你只需要这样的东西:

class Load(QtCore.QThread):

    onProgress = QtCore.Signal(int)

    def __init__(self, parent):
        QtCore.QThread.__init__(self, parent)
        self.parent = parent

    def run(self):
        '''
        '''
        stacks = []
        count = 100
        for i in range(count):
            # do something ... 
            self.onProgress.emit(count)