How to signal from a running QThread back to the PyQt Gui that started it?

后端 未结 1 1662
挽巷
挽巷 2020-12-31 22:51

I am trying to understand how to use signaling from a Qthread back to the Gui interface that started.

Setup: I have a process (a simulation) that needs to run almos

相关标签:
1条回答
  • 2020-12-31 23:25

    The problem here is simple: your SimulRunner never gets sent a signal that causes it to start its work. One way of doing that would be to connect it to the started signal of the Thread.

    Also, in python you should use the new-style way of connecting signals:

    ...
    self.simulRunner = SimulRunner()
    self.simulThread = QThread()
    self.simulRunner.moveToThread(self.simulThread)
    self.simulRunner.stepIncreased.connect(self.currentStep.setValue)
    self.stopButton.clicked.connect(self.simulRunner.stop)
    self.goButton.clicked.connect(self.simulThread.start)
    # start the execution loop with the thread:
    self.simulThread.started.connect(self.simulRunner.longRunning)
    ...
    
    0 讨论(0)
提交回复
热议问题