Hi all,

I'm developing a downloads application and I have created a QThread for that 
reason. I start the QThread with no problems, but when I try terminate it 
clicking on cancel pushbutton, I can't, application freezes. Thanks in 
advance. Here the code:

---

class MainWindow(QMainWindow):
        def __init__(self, parent = None):
                QMainWindow.__init__(self, parent)
                ...
                self.pbCancel=QPushButton(self.tr("Cancel"))
                self.connect(self.pbCancel, SIGNAL("clicked()"), self.cancel)
                ...
        def download(self):
                ...
                self.threadDownload = Download(url, path, filename)
                self.threadDownload.start()

        def cancel(self):
                self.threadDownload.terminate()
                self.threadDownload.wait()

class Download(QThread):
        def __init__(self, url, path, filename, parent = None):
                QThread.__init__(self, parent)
                self.path=path
                self.url=url
                self.filename=filename

        def run(self):
                os.chdir(self.path)
                
urllib.urlretrieve(self.url,self.filename,reporthook=self.myreporthook)
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to