[PyQt] processevents needed for qthreads?
apaku at gmx.de
Fri Aug 12 10:43:06 BST 2011
On 12.08.11 11:12:00, Peter Bienstman wrote:
> I have a threaded program which works fine under Linux, but crashes sometimes
> under Windows. My suspicion is that this is because I use
> QtCore.QCoreApplication.processEvents, for which I read everywhere that this
> is to be avoided and is a crutch for poor design.
> Also, many tutorial examples don't seem to require processEvents, but in my
> case, slots in the GUI main thread don't soom to get called unless I use
> I'm obviously missing something about threads and Qt here, but can somebody
> have a look at my code and see what is going wrong?
First of all, the example seems to be incomplete, there's no app.exec_()
and nothing creates a Server object.
However your problem lies in the init function of the Server. It waits
for the worker-thread to finish. Since you create the server from the
main thread as it seems you block the event processing and hence no
gui-updates and no cross-thread signals work.
This does not make any sense, since the point of a thread is to do work
in parallel and in your case your serializing everything again.
More information about the PyQt