Created
June 26, 2011 00:28
-
-
Save uranusjr/1047082 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef TASKTIMER_H | |
#define TASKTIMER_H | |
#include <QTImer> | |
#include <QString> | |
class TaskB : public QTimer | |
{ | |
Q_OBJECT | |
public: | |
TaskB(QObject *parent = 0) : QTimer(parent) | |
{ | |
connect(this, SIGNAL(timeout()), this, SLOT(doThing())); | |
} | |
void initialize(int start, int end) | |
{ | |
_start = start; | |
_end = end; | |
_current = 0; | |
} | |
signals: | |
void msg(QString msg); | |
void finished(); | |
private: | |
int _start; | |
int _end; | |
int _current; | |
private slots: | |
void doThing() | |
{ | |
_current++; | |
if (_current >= _end) | |
{ | |
stop(); | |
emit finished(); | |
return; | |
} | |
QString value; | |
value.sprintf("B%d", _current); | |
emit msg(value); | |
} | |
}; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment