I study Qthread. I'm confuse when qthread emit signal finished. Is signal finished emited when exit on run function?
class TestThread(QtCore.QThread):
customSignal = QtCore.pyqtSignal(['QString'])
def __init__(self):
QtCore.QThread.__init__(self)
def run(self):
print 'some code in run functions... '
self.customSignal.emit('OK')
print 'after this istruction qthread emit instantly finished signal?'
In run function I emit my custom signal that is intercepted by other class.In other class I receive a signal and I also check if Qthread is runnig:
print 'TestThread is running? - ', self.myTestTh.isRunning()
and sometimes it print True!!! So, it seems that Qthread not finish instantly when exit on run function So, Can I intercept also a finished signal to be sure that Qthread is not running?
QThread as a finished()
signal that you can listen to if you want to be notified when the thread actually quits.
Also you can do something like this:
myThread.quit();
myThread.wait();
where the call to wait()
will block until your thread as properly finished.