QThread没有发出我自己的信号

2024-04-19 05:31:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要使用QThreads发出自己的信号,但它仍然不起作用。这是我的线程类:

class Thread(QThread):

    startDestroy = Signal()

    def __init__(self):
        super(Thread, self).__init__()

    def run(self):
        self.startDestroy.emit()

需要发出信号startDestroy:

我的主要课程:

class MainForm(QDialog, Ui_Dialog):

    def __init__(self):
       super(MainForm, self).__init__()
       .
       .
       .
       self.thread = Thread()

    def setupSignals(self):
       .
       .
       .
       self.thread.startDestroy.connect(self.strDestroy)

我只得到这个错误,我不知道为什么:

self.thread.startDestroy.connect(self.strDestroy) AttributeError: 'builtin_function_or_method' object has no attribute 'startDestroy'


Tags: self信号initdefconnect线程threadclass