Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/phyCounter.cpp b/phyCounter.cpp
- index 750f497..b6cc2e4 100644
- --- a/phyCounter.cpp
- +++ b/phyCounter.cpp
- @@ -1,6 +1,7 @@
- #include "phyCounter.h"
- -
- +#include <QTimerEvent>
- phyCounter::phyCounter(QObject *parent) : QObject(parent) {
- + timerID_ = startTimer(1000);
- }
- void phyCounter::startCount() {
- @@ -11,3 +12,12 @@ void phyCounter::startCount() {
- dynamic_cast<phyThread*>(thread())->phySleep(1000);
- }
- }
- +
- +void phyCounter::timerEvent(QTimerEvent *)
- +{
- + static int i=0;
- + emit count(i++);
- + if (i > 4) {
- + killTimer(timerID_);
- + }
- +}
- diff --git a/phyCounter.h b/phyCounter.h
- index d8a6502..6c530c4 100644
- --- a/phyCounter.h
- +++ b/phyCounter.h
- @@ -1,6 +1,8 @@
- #include <QObject>
- #include "phyThread.h"
- +class QTimerEvent;
- +
- class phyCounter : public QObject {
- Q_OBJECT
- public:
- @@ -8,4 +10,8 @@ public:
- void startCount();
- signals:
- void count(int);
- + protected:
- + void timerEvent(QTimerEvent *);
- + private:
- + int timerID_;
- };
- diff --git a/phyView.cpp b/phyView.cpp
- index 9c4cb81..a93f549 100644
- --- a/phyView.cpp
- +++ b/phyView.cpp
- @@ -15,7 +15,6 @@ phyView::phyView(QWidget *parent) : QGraphicsView(parent) {
- phyCounter *counter = new phyCounter();
- counter->moveToThread(thread);
- connect(counter, SIGNAL(count(int)), this, SLOT(changeCount(int)));
- - counter->startCount();
- }
- phyView::~phyView() {
Advertisement
Add Comment
Please, Sign In to add comment