我有GUI应用程序使用qwebview通过长循环进行Web自动化过程所以我使用QThread来做这个,但我不能终止线程,我的代码在下面
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()'))
Run Code Online (Sandbox Code Playgroud)
这个代码在启动线程时工作正常但是无法停止循环并且浏览器仍在运行,即使我向它调用close事件并且它从GUI中消失
单击按钮时,我打开了一些向导,此向导在主模型的子模型中插入了一些值,因此我需要将一些数据从主模型发送到向导
数据包括当前 ID