Hi

I have a problem with QTimer, I call the start function but don't work:

Qt Code:
  1. class MyClass : public QObject {
  2.  
  3. Q_OBJECT
  4.  
  5. private:
  6. QTimer* timer;
  7.  
  8. private slots:
  9. void executeMyTimer();
  10.  
  11. ....
  12. };
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. MyClass::MyClass() : QObject() {
  2. this->timer = new QTimer(this);
  3. this->timer->setInterval(500);
  4. connect(this->timer, SIGNAL(timeout()), this, SLOT(executeMyTimer()));
  5. this->timer->start();
  6. }
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:

Qt Code:
  1. int main(int argc, char** argv) {
  2. QApplication app(argc, argv);
  3.  
  4. MyApp app;
  5. QTimer::singleShot(0, &app, SLOT(run()));
  6.  
  7. return app.exec();
  8. }
To copy to clipboard, switch view to plain text mode 

And the run function:
Qt Code:
  1. MyApp::run() {
  2. // .....
  3.  
  4. for(;;) {
  5. // ...
  6. }
  7. }
To copy to clipboard, switch view to plain text mode 

Somebody can help me please?