3

QTimerを持つスレッドがあります。アプリケーションを再起動せずに、実行間隔を動的に変更できるのが好きです。これは、QThreadrunメソッド内のコードです。

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();;
}
4

1 に答える 1

9

方法がありsetIntervalます。

于 2011-05-29T09:18:19.177 に答える