hello,
In my application I want that when a loop is being executed,each time the control transfers to the loop,each execution must be delayed with a particular time.Can anyone tell me how can i do this?
Thank you.
hello,
In my application I want that when a loop is being executed,each time the control transfers to the loop,each execution must be delayed with a particular time.Can anyone tell me how can i do this?
Thank you.
EDIT (removed wrong solution). EDIT (to add this other option):
Another way to use it would be subclass QThread since it has protected *sleep methods.
QThread::usleep(unsigned long microseconds);
QThread::msleep(unsigned long milliseconds);
QThread::sleep(unsigned long second);
Here's the code to create your own *sleep method.
#include <QThread>
class Sleeper : public QThread
{
public:
static void usleep(unsigned long usecs){QThread::usleep(usecs);}
static void msleep(unsigned long msecs){QThread::msleep(msecs);}
static void sleep(unsigned long secs){QThread::sleep(secs);}
}
and you call it by doing this:
Sleeper::usleep(10);
Sleeper::msleep(10);
Sleeper::sleep(1);
This would give you a delay of 10 microseconds, 10 milliseconds or 10 seconds, accordingly.
Hope this helps.