#include <QtCore>
#include <QDebug>
{
Q_OBJECT
public:
{
connect(&t1, SIGNAL(timeout()), SLOT(p1()));
connect(&t2, SIGNAL(timeout()), SLOT(p2()));
connect(&t3, SIGNAL(timeout()), SLOT(p3()));
connect(&t4, SIGNAL(timeout()), SLOT(p4()));
connect(&t5, SIGNAL(timeout()), SLOT(p5()));
connect(&t6, SIGNAL(timeout()), SLOT(p6()));
time.start();
t1.start(500);
t2.start(600);
t3.start(100);
t4.start(1000);
t5.start(3000);
t6.start(5000);
}
public slots:
void p1() { qDebug() << "p1 at" << time.elapsed(); usleep(6000); }
void p2() { qDebug() << "p2 at" << time.elapsed(); usleep(4000); }
void p3() { qDebug() << "p3 at" << time.elapsed(); usleep(4000); }
void p4() { qDebug() << "p4 at" << time.elapsed(); usleep(6000); }
void p5() { qDebug() << "p5 at" << time.elapsed(); usleep(3000); }
void p6() { qDebug() << "p6 at" << time.elapsed(); usleep(2000); }
private:
QTimer t1, t2, t3, t4, t5, t6;
};
int main(int argc, char **argv)
{
Dummy d;
return app.exec();
}
#include "main.moc"
#include <QtCore>
#include <QDebug>
class Dummy: public QObject
{
Q_OBJECT
public:
Dummy(QObject *p = 0): QObject(p)
{
connect(&t1, SIGNAL(timeout()), SLOT(p1()));
connect(&t2, SIGNAL(timeout()), SLOT(p2()));
connect(&t3, SIGNAL(timeout()), SLOT(p3()));
connect(&t4, SIGNAL(timeout()), SLOT(p4()));
connect(&t5, SIGNAL(timeout()), SLOT(p5()));
connect(&t6, SIGNAL(timeout()), SLOT(p6()));
time.start();
t1.start(500);
t2.start(600);
t3.start(100);
t4.start(1000);
t5.start(3000);
t6.start(5000);
}
public slots:
void p1() { qDebug() << "p1 at" << time.elapsed(); usleep(6000); }
void p2() { qDebug() << "p2 at" << time.elapsed(); usleep(4000); }
void p3() { qDebug() << "p3 at" << time.elapsed(); usleep(4000); }
void p4() { qDebug() << "p4 at" << time.elapsed(); usleep(6000); }
void p5() { qDebug() << "p5 at" << time.elapsed(); usleep(3000); }
void p6() { qDebug() << "p6 at" << time.elapsed(); usleep(2000); }
private:
QTime time;
QTimer t1, t2, t3, t4, t5, t6;
};
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
Dummy d;
return app.exec();
}
#include "main.moc"
To copy to clipboard, switch view to plain text mode
Bookmarks