I have GUI application which uses qwebview to make web automation process through long loop so I used QThread to do this but I can't terminate the thread, my code is below
class Main(QMainWindow):
def btStart(self):
self.mythread = BrowserThread()
self.connect(self.mythread, SIGNAL('loop()'), self.campaign_loop, Qt.AutoConnection)
self.mythread.start()
def btStop(self):
self.mythread.terminate()
def campaign_loop(self):
loop goes here
class BrowserThread(QThread):
def __init__(self):
QThread.__init__(self)
def run(self):
self.emit(SIGNAL('loop()'))
this code is working fine in starting thread but fail to stop the loop and browser still running even if I call close event to it and it disappears from GUI
EDIT: it works on linux too, I tried this on raspberry pi 4 and it works fine
the point is to make the main loop in the " run " method because " terminate " function is stopping the loop in " run " not the thread its self here is a working example for this,
but unfortunately it works on windows only