开发者

QTimer stops and starts by itself

Here is how I use QTimer:

Q开发者_如何学JAVATimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
timer->setInterval(1000);
timer->start();

Program monitors update() function and prints the current time in it. Normally it works as expected, it prints time at every second, but when program starts to process other jobs, there would be some breaks like 5 to 8 secs.

Qt Documentation mentions about accuracy issues like 1 ms, obviously I have another problem. Any ideas ?


QTimer (and all event-base message deliveries) is not interrupt driven. That means you are not guaranteed you will receive the event right when it's sent. The accuracy describes how the event is triggered, not how it's delivered.

If you are not doing threaded process on long job, call QCoreApplication::processEvents() periodically during the long process to ensure your slot gets called.


Your other jobs run for several seconds, and there's no event processing during these. You'd need to thread the jobs in order to get the responsiveness you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜