Hi phil,

according to the docs, the QThread::run method should call exec (and
thus start a new event loop), but this code doesn't work (it never ends)


> #!/usr/bin/env python
> #-*- coding: utf-8 -*-
> 
> from PyQt4.Qt import *
> 
> app = QApplication([])
> 
> class Start(QEvent):
>     def __init__(self):
>         QEvent.__init__(self, QEvent.User)
>     
> class Receiver(QObject):
>     def doSomething(self):
>         print 'doSomething'
>         qApp.quit()
> 
> class Main(QObject):
>     def test(self):
>         r = self._r = Receiver()
>         t = self._t = QThread()
>         r.moveToThread(t)
>         QObject.connect(self, SIGNAL('test'), r.doSomething)
>         t.start()
>         self.emit(SIGNAL('test'))
> 
> main = Main()
> main.test()
> app.exec_()

If, intead of a QThread, I use a class like this:

> class MyThread(QThread):
>     def run(self):
>         return self.exec_()


all works as expected.


best regards
david

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to