Hi
I have a problem with QTimer, I call the start function but don't work:
Q_OBJECT
private:
private slots:
void executeMyTimer();
....
};
class MyClass : public QObject {
Q_OBJECT
private:
QTimer* timer;
private slots:
void executeMyTimer();
....
};
To copy to clipboard, switch view to plain text mode
this
->timer
= new QTimer(this);
this->timer->setInterval(500);
connect(this->timer, SIGNAL(timeout()), this, SLOT(executeMyTimer()));
this->timer->start();
}
MyClass::MyClass() : QObject() {
this->timer = new QTimer(this);
this->timer->setInterval(500);
connect(this->timer, SIGNAL(timeout()), this, SLOT(executeMyTimer()));
this->timer->start();
}
To copy to clipboard, switch view to plain text mode
I've tried to use QBasicTimer, QTimer::singleShot() and QObject::startTimer() but don't work...
I think that the problem is that my app have an infinite loop. I call the run() function like this:
int main(int argc, char** argv) {
MyApp app;
QTimer::singleShot(0,
&app,
SLOT(run
()));
return app.exec();
}
int main(int argc, char** argv) {
QApplication app(argc, argv);
MyApp app;
QTimer::singleShot(0, &app, SLOT(run()));
return app.exec();
}
To copy to clipboard, switch view to plain text mode
And the run function:
MyApp::run() {
// .....
for(;;) {
// ...
}
}
MyApp::run() {
// .....
for(;;) {
// ...
}
}
To copy to clipboard, switch view to plain text mode
Somebody can help me please?
Bookmarks