[Qt-interest] Overhead considerations: QObject::startTimer(), QTimer, QBasicTimer
Kishore Jonnalagadda
kitts.mailinglists at gmail.com
Tue Sep 13 14:53:37 CEST 2011
On Tuesday 13 Sep 2011 5:24:04 PM Pritam Ghanghas wrote:
> I need to use a lot of timers in my application. There are three
> approaches to timer in qt. I looked at documentation and couldn't
> anything that compares their performance or overhead figures.
>
>
> QObject::startTimer(), QBasicTimer look very similar in functionality.
> QTimer is easy and neat to use but comes with QObject overhead. I was
> wondering "how much is this overhead? and are there other overheads to
> using QTimer instead of the other two?"
QBasicTimer is just a simple wrapper that keeps a copy of the timerId returned
by startTimer(). In fact the object's size is equal to the size of the timerId
(int).
Note that when using startTimer() or QBasicTimer you are responsible for
managing singleShot mode if applicable and also you will have to save the
interval value if you need it again after you have started the timer as there
is no way (AFAIK) to query the interval of a timer given it's id.
--
Cheers!
Kishore
More information about the Qt-interest-old
mailing list