[Qt-interest] Animation with QGraphicsView
Karol Krizka
kkrizka at gmail.com
Sun May 3 00:56:09 CEST 2009
On Saturday 02 May 2009 04:39:04 Freddie Witherden wrote:
> Hi all,
>
> My application uses QGraphicsView to model a physical system, in which
> the position of objects (x,y) is a function of time. Currently my
> application works by using a timer set to fire every m_timeStep
> milliseconds and calling scene()->advanced() in the timer event.
>
> This causes each simulated object to advance by m_timeStep and update
> its position. The problem is that if the system is unable to keep
> manage 60 advances a second the simulation lags. Obviously this is not
> the right way to go about it.
>
> While it is not hard to de-couple the two, so we get the amount of
> time passed since the last update and add that to get the current
> simulation time. (As the simulation can be paused.)
>
> However, what is the best way to get Qt to try and pump out as many
> frames as possible. There has to be a better way than a timer.
>
Take a look at QTimeLine:
http://doc.trolltech.com/4.5/qtimeline.html
That is what I use for animations. Furthermore, it allows you to run your
animation backwards. ;)
--
Cheers,
Karol Krizka
http://www.krizka.net
More information about the Qt-interest-old
mailing list