utilizes.h
===============================================================
#ifndef UTILIZES_H
#define UTILIZES_H
class Utilizes
{
public:
Utilizes();
public:
static void sleep(int secs);
static void msleep(int msecs);
};
#endif
utilizes.cpp
===============================================================
#include "utilizes.h"
#include <QCoreApplication>
#include <QTime>
Utilizes::Utilizes()
{
}
void Utilizes::sleep(int secs)
{
QTime dieTime = QTime::currentTime().addSecs(secs);
while( QTime::currentTime() < dieTime )
{
QCoreApplication::processEvents(QEventLoop::AllEvents, secs * 1000);
}
}
void Utilizes::msleep(int msecs)
{
QTime dieTime = QTime::currentTime().addMSecs(msecs);
while( QTime::currentTime() < dieTime )
{
QCoreApplication::processEvents(QEventLoop::AllEvents, msecs);
}
}