[PyQt] processEvents on QlistWidget operations does nothing

Andreas Pakulat apaku at gmx.de
Sun Jan 27 22:22:36 GMT 2008


On 27.01.08 13:36:37, Scott Aron Bloom wrote:
> > Its not about replacing 1 line of code, its about properly designing
> > your applications business logic. Moving heavy work into a thread is
> the
> > right thing to do (or separate process). QApplication::processEvents
> is
> > the ugly hack for those who are not able to use threads properly.
> > 
> > Andreas
> > 
> But... adding 1 item to a list view.. is not heavy work.. And neigher
> does it appear that the creation of the complete list of items...

Right, but thats not what the code actually does and I also suspect that
adding the item is still done in the main thread.

> If the code was actually downloading the content of each URL... then I
> would put it in a thread..

Thats exactly what the urllib-call (notice the read() at the end of that
line) does, it opens the url and reads the whole file. And I suspect
that this is the part that got moved into a separate thread. Now maybe
I've just seen far worse code, but a short QThread::run() that iterates
over urls, downloads them and then emits a signal for each with whatever
content is needed doesn't look ugly to me.

Andreas

-- 
This will be a memorable month -- no matter how hard you try to forget it.


More information about the PyQt mailing list