PDA

View Full Version : Pause / Wait / Sleep for the application herself



Nyphel
14th June 2007, 15:44
Hi,

I've finished the developement of an application, and I would like to add a small pause of 10 seconds in a function...

I've seen the Pause/Wait/Sleep functions, but the don't apply to an application. We can use them only in particular cases, like threads. I don't want to rewrite my application with threads...

But I've also heard that a QApplication is a thread. So, is there anything to create a small pause in my application ? Perhaps should I call a system function like system("pause") ?

Thanks for your hints :)

spud
14th June 2007, 16:52
You can call sleep() in any function but if it is in the main (GUI) thread your application will freeze and become unresponsive. You could try:


while(timeIsntUp)
QCoreApplication::processEvents();

You will probably have to block the user from repeating the action which lead to the function being called. I.e. graying out a button or something similar.