Qt实现监听功能

来源:互联网 发布:mac os sierra beta4 编辑:程序博客网 时间:2024/03/29 23:01

Qt每隔0.5秒或一秒就监听函数的返回值:

1.你的类继承自QObject,并实现virtual void timerEvent(QTimerEvent * event),然后启动的时候调用startTimer(500), 在你timerEvent函数里判断你的那个返回值

2.创建一个QTimer对象
    QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(update()));
    timer->start(500);

在udpate函数里做判断

原创粉丝点击