[Interest] QProgressDialog not showing & processEvents()

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Mon Nov 18 08:59:14 CET 2013


> You have two viable approaches here:
> * break up the saving method into chunks. That is, do a small part of the
> work of the saving, queue the next piece of work to be done, and return to
> the eventloop. The eventloop will then trigger the next queued piece of the
> work being done. This way, there is no need for processEvents() at all.
> * move your saving code to a worker object, and execute it in a separate
> thread. Also, no need to use processEvents, as the heavy lifting is done
> outside of the GUI thread.

I'd too suggest the separate thread method as it's more generic and
will across different scenario's.

The only thing that you need to worry about is that your thread's
actions are in sync with what the GUI is showing. Eg: in case you
provide a cancel button, you'll have to inform the worker thread to
abort and wait for it to exit cleanly.

HTH,
-mandeep



More information about the Interest mailing list