PDA

View Full Version : QBasicTimer and lightweight QT Objects :



tonnot
7th October 2010, 17:39
The QT doc says :
Unlike QTimer, QBasicTimer doesn't inherit from QObject....
This makes QBasicTimer a more lightweight alternative to QTimer.

Any link to lightweight QT literature or articles ?

The code for Wiggly Example is :

void AnalogClock::timerEvent(QTimerEvent *event)
{
if (event->timerId() == timer.timerId()) {
++step;
update();
} else {
QWidget::timerEvent(event);
}
}
And my question is who more can call my timerEvent ? Can I delete the timerId() check ?

wysota
7th October 2010, 17:41
Any link to lightweight QT literature or articles ?
no.


And my question is who more can call my timerEvent ?
A subclass or superclass.

Can I delete the timerId() check ?
You can do anything you want.

tonnot
7th October 2010, 17:54
Thanks Wisota
You answer me to 'who more call my timerEvent' >> A subclass or superclass...
But If I'm sure that this event are only called by me .... can i use a code without timerid() check ? or maybe occur something unexpected ?
Thanks

wysota
7th October 2010, 18:35
But If I'm sure that this event are only called by me .... can i use a code without timerid() check ?
If you are sure then you don't need the check. But with Qt you can't be sure unless you are sure Qt libraries you use will never be changed.

I don't see a point in all this discussion. If you are looking for ways to make your application faster then you are looking in a wrong place, removing this check (which is probably inlined anyway) will save you less cpu cycles than the number of cpu cycles it takes to create the stack frame for the timerEvent() call. Don't look for ways to optimize highways, optimize small roads instead.