| 1234567891011121314151617181920212223242526272829303132333435 |
- #include "snctimer.h"
- SNCTimer::SNCTimer(int seconds,QObject *parent) :
- QThread(parent)
- {
- m_stop = false;
- m_seconds = seconds;
- }
- void SNCTimer::abort()
- {
- m_stop = true;
- }
- void SNCTimer::run()
- {
- m_stop = false;
- while(!m_stop)
- {
- QTime dieTime = QTime::currentTime().addMSecs(1000*m_seconds);
- QTime c;
- c.start();
- while( QTime::currentTime() < dieTime )
- {
- QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
- msleep(10);
- if(m_stop)
- break;
- }
- break;
- emit timerOut();
- }
- }
|