Search code examples
timerqthread

How can i set QTimer interval to change dynamically without restarting the app


I have thread that has QTimer , i like it to be able to change its execution interval dynamclly without restarting the application : this is the code inside the QThread run method :

void myThread::run()
{
      QTimer timer1;
      connect(&timer1, SIGNAL(timeout()),
              this,SLOT(fire(),Qt::DirectConnection));

      qDebug() << "A::run() worker thread -- currentThread:" << currentThread();

      timer1.start(1000);

      QThread::exec();;
}

Solution

  • There is a setInterval method.