Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1322339
  • 博文数量: 177
  • 博客积分: 3640
  • 博客等级: 中校
  • 技术积分: 1778
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-27 16:51
文章分类

全部博文(177)

文章存档

2014年(1)

2013年(10)

2012年(3)

2011年(163)

分类: LINUX

2011-05-14 08:17:11

QTimer的用法比较简单,看官方提供的使用例:
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
timer->start(1000);每秒超时调用this->update()。
QT也提供了另外一个类:QBasicTimer,其用法例:
#include
#include
#include
class MyClass:public QObject
{
public:
MyClass(){};
protected:
void timerEvent( QTimerEvent *event ){
qDebug() << "Time out timer id" << event->timerId();
}
};
int main( int argc, char *argv[] )
{
QCoreApplication app( argc, argv );
MyClass *mc = new MyClass();
QBasicTimer bt;
bt.start( 120 * 1000, mc );
return app.exec();
}
发生超时事件的时候,会调用的mc->timerEvent(),而没有timerout()信号。
在WebKit的分析中有碰到QBasicTimer的使用。
阅读(707) | 评论(0) | 转发(0) |
1

上一篇:QLCDNumber Class Reference

下一篇:Qt this

给主人留下些什么吧!~~