QThread: Destroyed while thread is still running

前端 未结 1 1743
傲寒
傲寒 2020-12-29 06:36

I\'m having problem with QThreads in python. I want to change background color of label. But My application crash while starting. \"QThread: Destroyed while thread is still

相关标签:
1条回答
  • 2020-12-29 07:29

    You're not storing a reference to the thread after it's been created, which means that it will be garbage collected (ie. destroyed) some time after the program leaves MainWindows __init__. You need to store it at least as long as the thread is running, for example use self.statusTh:

    self.statusTh = statusThread(self)
    self.connect(self.statusTh, SIGNAL('setStatus'), self.st, Qt.QueuedConnection)
    self.statusTh.start()
    
    0 讨论(0)
提交回复
热议问题