Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 7

Qt-interest Archive, July 2007
Delay the display of a QDialog


Message 1 in thread

Hi folks !


I'd need to delay a bit the display of a QDialog, in order to avoid
flickering when the process at hand is very short. 

eg :

when copying files, the "copy on progress" dialog should be displayed only
if the files to copy are numerous, ie for exemple only after one sec, 
BUT
the interaction with other windows should be freezed even during the first
seconds.



In such a case case, I'd like to set up a QDialog, so that the blocking
function exec :
- start copying files 
- freeze interaction with other window, such as a QDialog does
- does not display the dialog (ie : does not call QDialog::exec ?)
- but starts a 1 second timer

then :
- if the timer elapses, the dialog is actually shown, with cancel button,
progress bar, etc.
- when copying is finished before the timer elapses, my blocking exec()
method would return ; if the timer has not elapsed yet, the QDialog is
never displayed



What would you advice to obtain such a behavior ?

Thanks much,
Best-
Nicolas

--
 [ signature omitted ] 

Message 2 in thread

Dnia wtorek, 31 lipca 2007, Nicolas Castagne napisaÅ:
> What would you advice to obtain such a behavior ?

You can use another thread for copying (derive from QThread) and call wait() 
to wait for 1 second. If wait() will return true (thread finished his job) 
then your files are already copied - if will return false you can exec your 
dialog.

Regards,
-- 
 [ signature omitted ] 

Attachment: signature.asc
Description: This is a digitally signed message part.


Message 3 in thread

Ty very much RafaÅ,


Unfortunately, calling wait() is not pbly not the good solution, since the
whole event loop is then blocked ; if the "time to wait" is big (pbly more
than a sec in my case), the paintEvent, for example, would not be processed
any more.

The problem comes from the fact that I am not able to enter the local event
loop of a QDialog appart calling exec() - which, in turn, shows() the
dialog.
Or, similarly : I am not able to hide a QDialog without quiting its local
event loop.



Now, concnerning threads... I use a worker thread already.


Best-
Nicolas

RafaÅ Cygnarowski wrote:

> Dnia wtorek, 31 lipca 2007, Nicolas Castagne napisaÅ:
>> What would you advice to obtain such a behavior ?
> 
> You can use another thread for copying (derive from QThread) and call
> wait() to wait for 1 second. If wait() will return true (thread finished
> his job) then your files are already copied - if will return false you can
> exec your dialog.
> 
> Regards,

--
 [ signature omitted ] 

Message 4 in thread

Dnia wtorek, 31 lipca 2007, Nicolas Castagne napisaÅ:
> Unfortunately, calling wait() is not pbly not the good solution, since the
> whole event loop is then blocked ; if the "time to wait" is big (pbly more
> than a sec in my case), the paintEvent, for example, would not be processed
> any more.

You still can wait() for shorter time few times and call 
QApplication::processEvents().

Regards,
-- 
 [ signature omitted ] 

Attachment: signature.asc
Description: This is a digitally signed message part.