0

我正在使用这样的东西:

import threading
from PySide import QtCore

class Smt(threading.Thread):
    foo_signal = QtCore.Signal(object)

    def __init__(self):
        threading.Thread.__init__(self)

    def run(self);
        while True:
            pass # and so..

然后我开始它:

a = Smt()
a.foo_signal.connect(function)
a.start()

输出是:

AttributeError: 'PySide.QtCore.Signal' object has no attribute 'connect'

如果我使用QtCore.QThread而不是threading.Thread- 它效果很好。但我不想使用QThread.

甚至可能吗?

4

1 回答 1

3

Signals require that the class which is using them be inherited from a QObject (Or any class which also inherits QObject). So you can either switch to using a QThread or also inherit from QObject and call QtCore.QObject.__init__(self) in your __init__

于 2013-08-02T19:33:17.857 回答