Skip to content

Instantly share code, notes, and snippets.

@uranusjr
Created June 26, 2011 00:28
Show Gist options
  • Save uranusjr/1047082 to your computer and use it in GitHub Desktop.
Save uranusjr/1047082 to your computer and use it in GitHub Desktop.
#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