Qt-interest Archive, July 2007
qtimer behaivor
Message 1 in thread
i apologize for not being able to provide a good code snippet, but it's
hard for me to figure out exactly what would be relevant to my problem,
short of the entire application (which is huge).
basically, for some reason, in a particular situation -- in which there
is NO call to QTimer::setInterval() -- the QTimer i'm using resets its
interval to what i would imagine to be, based on refresh rate and cpu
utilization, 1ms. the only problem is that, in debugging the
application, the object still shows a value of 100ms, which is clearly
not at all the case.
also, the ONLY QTimer functions called in this particular situation
(which only involves loading datafiles, and very little qt-related
activity) are as follows:
gTimer = new QTimer(this);
QObject::connect(gTimer, SIGNAL(timeout()), this, SLOT(DisplayInfo()));
gTimer->start(100);
where DisplayInfo() is a function for polling a simulation model and
updating the gui with the relevant information.
if this is a known issue, i haven't seen anything about it and would
like to hear more about it, but if not i can try to post more specifics
on the application if necessary.
thanks,
jeff.
--
[ signature omitted ]
Message 2 in thread
Jeff Fisher wrote:
> i apologize for not being able to provide a good code snippet, but it's
> hard for me to figure out exactly what would be relevant to my problem,
> short of the entire application (which is huge).
>
> basically, for some reason, in a particular situation -- in which there
> is NO call to QTimer::setInterval() -- the QTimer i'm using resets its
> interval to what i would imagine to be, based on refresh rate and cpu
> utilization, 1ms. the only problem is that, in debugging the
> application, the object still shows a value of 100ms, which is clearly
> not at all the case.
>
> also, the ONLY QTimer functions called in this particular situation
> (which only involves loading datafiles, and very little qt-related
> activity) are as follows:
>
> gTimer = new QTimer(this);
> QObject::connect(gTimer, SIGNAL(timeout()), this, SLOT(DisplayInfo()));
> gTimer->start(100);
>
> where DisplayInfo() is a function for polling a simulation model and
> updating the gui with the relevant information.
>
> if this is a known issue, i haven't seen anything about it and would
> like to hear more about it, but if not i can try to post more specifics
> on the application if necessary.
>
>
> thanks,
> jeff.
...i'm an idiot. that particular chunk of code was getting executed
several times, meaning that gTimer was being reallocated without being
deallocated first. changed everything to:
QTimer gTimer;
[...]
QObject::connect(>imer, SIGNAL(timeout()), this, SLOT(DisplayInfo()));
gTimer.start(100);
and everything works great.
--
[ signature omitted ]