1、包含头文件

  #include<QTimer>

2、

QTimer *timer = new QTimer(this);      //this 指定父对象,可自动回收
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
timer->start(1000);

startTimer()函数的作用是使定时器开始,并且返回一个定时器标识符,或者如果不能开始计时,返回0。当定时器事件发生时,虚函数timeEvent(QTimeEvent*)被调用为QTimerEvent时间参数类。重新实现这个函数可以获得定时器事件。 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-09
  • 2022-01-10
  • 2021-06-15
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-18
  • 2022-12-23
相关资源
相似解决方案