View Full Version : How to wait 2 seconds before continue
raphaelf
25th June 2008, 11:23
Hi everybody,
how could i wait 2 seconds one my code before i continue?
I know that with QTimer its possible, but i need a example..
Can somebody send me a example? :o
lyuts
25th June 2008, 11:56
1. Create QTimer
2. connect QTimer's signal (timeout) to your slot
3. start it
QTimer *timer = new QTimer;
timer->setSingleShot(true);
connect(timer, SIGNAL(timeout()), this, SLOT(yourSlot()));
timer->start(2000);
...
void yourClass::yourSlot()
{
}
or maybe you just want to do sleep(2). I don't the reasons why you need to wait.
raphaelf
25th June 2008, 12:12
Thanks it works!!!
:D
Btw, QTimer has a convenient static method which can combine all that to a single statement:
QTimer::singleShot(2000, this, SLOT(yourSlot()));
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.