[PyQt] Threads with PyQt. Qt's or Python's?

Christoph Burgmer chrislb at gmx.de
Mon Jan 19 15:36:08 GMT 2009


Am Monday, 19. January 2009 schrieb Giovanni Bajo:
> On 1/19/2009 3:13 PM, eliben wrote:
> > I've seen various references to this issue before, but nothing to fully
> > address it as I'd expect.
> >
> > Can you comment on the pros and cons of using QThread vs Python's threads
> > with PyQt?
> >
> > I'll begin: on the surface, Python's threads make more sense because
> > they're Qt independent and can be ported between apps that don't
> > necessarily depend on Qt (for example a web version of a GUI app). The
> > Python thread API is powerful enough for all uses, it seems.
> >
> > However, there are concerns. Perhaps QThreads are more efficient? Or
> > maybe more tightly integrated with the other parts of PyQt, so it's
> > easier to use them?
>
> It's mostly the same. The main difference is that QThreads are better
> integrated with Qt (asynchrnous signals/slots, event loop, etc.). Also,
> you can't use Qt from a Python thread (you can't for instance post event
> to the main thread through QApplication.postEvent): you need a QThread
> for that to work.

I am doing a
QCoreApplication.postEvent()
out of "run()" from a "threading.Thread" class without any problems.

Christoph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090119/574e99ab/attachment.html


More information about the PyQt mailing list