[PyQt] Question about QTimer and QThreads

Andreas Pakulat apaku at gmx.de
Mon Oct 29 08:15:45 GMT 2007

On 28.10.07 18:31:25, Darren Dale wrote:
> I am trying to understand how to run a second event loop using a qthread. The 
> Qt docs indicate this is possible, but I haven't found any examples. I have a 
> simple example that I think should work, but doesn't. When I run my thread's 
> exec_(), it blocks. The actual application I am writing calls the qApp's 
> exec_ before the thread's exec_, but even then the thread's exec_ blocks 
> further execution. Does anyone know how to do this?

Quite easy: Run exec_() inside the new thread, not inside your GUI/main
thread. To do that add a run() method which only contains


Then from the main thread (i.e. after the text.connect) start your
thread by calling a.start(). You might need to add another function to
your thread-class that starts the timer, but I'm not sure might as well
just work as is...


You're at the end of the road again.

More information about the PyQt mailing list