[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] QThread::run does not worl as expected
From: Phil Thompson <phil () riverbankcomputing ! com>
Date: 2010-06-29 16:28:10
Message-ID: ce555f53261090e250e42b6a4ee7e4de () localhost
[Download RAW message or body]
On Thu, 17 Jun 2010 14:42:46 +0200, David Mugnai <dvd@develer.com> wrote:
> 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.
Should be fixed with tonight's SIP snapshot.
Thanks,
Phil
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic