[Interest] QProgressDialog not showing & processEvents()

Konrad Rosenbaum konrad at silmor.de
Mon Nov 18 08:15:48 CET 2013


Hi,

it is always safe to call processEvents yourself. If the QProgressDialog has 
display issues it obviously does not get enough CPU to update itself, calling 
processEvents more often may(!!) help.

When I want to see a QProgressDialog early I normally force the issue by 
calling show() immediately. That's more reliable than leaving it to the 
internal heuristics. Especially if there may be a long time before the first 
call to processEvents.

If you are just copying a lot of data it may be a good idea to do this in a 
separate thread and just throw the updates (Qt::QueuedConnection!) to the GUI 
thread from time to time. This way the GUI remains fully intact. (Hint: if you 
delete objects during saving: use deleteLater; if you allocate new stuff do it 
in a slot with BlockingQueuedConnection or use moveToThread).



	Konrad

On Friday, Friday 15 November 2013 at 14:05, Etienne Sandré-Chardonnal wrote:
> Dear all,
> 
> I have a long file saving function (gigabytes - several minutes) and I am
> trying to use QProcessDialog. I am using it the Modal way as explained in
> the documentation. However, the dialog appears after about 50 seconds,
> despite having set the minimumDuration to 0, and called setValue() several
> times before.
> 
> Googling for the issue says I need to call QApplication::processEvents
> regularly in order for the GUI to refresh. However, the doc says :
> 
> "If the progress dialog is modal
> (seeQProgressDialog::QProgressDialog<qthelp://com.trolltech.qt.481/qdoc/qpr
> ogressdialog.html#QProgressDialog>()), setValue()
> callsQApplication::processEvents<qthelp://com.trolltech.qt.481/qdoc/qcorea
> pplication.html#processEvents>(), so take care that this does not cause
> undesirable re-entrancy in your code"
> 
> So I'm puzzled... Do I need to call it, or is it already called by
> setValue? In the example there are no explicit calls to processEvents().
> 
> Qt 4.8.1
> 
> Thanks!
> 
> Etienne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20131118/8f206d1b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20131118/8f206d1b/attachment.sig>


More information about the Interest mailing list