[PyQt] QThread not exiting

Andreas Pakulat apaku at gmx.de
Fri Oct 19 17:19:21 BST 2007


On 19.10.07 09:25:05, Kerri Reno wrote:
> I'm trying to run a progress bar in a QThread, while other stuff runs in the
> main thread.  I can't get the QThread to exit.  It just goes on forever.  My
> code is attached - please help!

You can't. GUI elements can not work outside the main thread. If you
have things that need a separate thread send signals from the threads
run() method or post events which then get captured by the gui elements
(either via a slot or a customEvent() function) and then can update the
gui apropriately.

Also if you access variables in your thread class from multiple threads
you want to protect them against concurrent access, for example by using
QMutexLocker with a QMutex.

Andreas

-- 
Advancement in position.


More information about the PyQt mailing list