I'm playing around with Qt, and I want to create a simple pause between two commands. However it won't seem to let me use Sleep(int mili);
, and I can't find any obvious wait functions.
I am basically just making a console application to test some class code which will later be included in a proper Qt GUI, so for now I'm not bothered about breaking the whole event-driven model.
I wrote a super simple delay function for an application I developed in Qt.
I would advise you to use this code rather than the sleep function as it won't let your GUI freeze.
Here is the code:
void delay()
{
QTime dieTime= QTime::currentTime().addSecs(1);
while (QTime::currentTime() < dieTime)
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}
To delay an event by n seconds - use addSecs(n)
.