[Qt-interest] QTimeLine valueForTime seems to work incorrectly

Parta lists4pghanghas at gmail.com
Tue Nov 17 11:29:34 CET 2009


Hi

I have a QTimeLine of 500ms for animating a QGraphicsViewItem. I have
a start position and end position for the same.
But I am getting framerate in the range of 15-20fps. I need more.
Though my CPU is not fully utilized, it doesn't give me more frames.
Then I subclassed QTimeLIne and reimplemented valueForTime() function
to have more control over the curve. I also placed a qDebug message
so that I can have a look at terminal how the value grows.
Here is the code that I used for valueForTime()

qreal tvTimeLine::valueForTime(int msec) const
{
    qreal pi = qreal(3.14159265359);
    qreal halfPi = pi / qreal(2.0);
    qreal linvalue = qreal(msec)/qreal(timer_duration);
    qreal sinProgress = qSin((linvalue * halfPi));
    qDebug() << "value of time " << msec << "is: "  <<  sinProgress;
    return sinProgress;
}

A simple sine progression.

Here is the output that I get

Here is output:

value at time  0 is:  0
value at time  0 is:  0
value at time  0 is:  0
value at time  0 is:  0
value at time  0 is:  0
value at time  0 is:  0
value at time  40 is:  0.125333
value at time  40 is:  0.125333
value at time  40 is:  0.125333
value at time  40 is:  0.125333
value at time  40 is:  0.125333
value at time  243 is:  0.691387
value at time  243 is:  0.691387
value at time  243 is:  0.691387
value at time  243 is:  0.691387
value at time  243 is:  0.691387
value at time  397 is:  0.948102
value at time  397 is:  0.948102
value at time  397 is:  0.948102
value at time  397 is:  0.948102
value at time  397 is:  0.948102
value at time  500 is:  1
value at time  500 is:  1
value at time  500 is:  1

Look at the output qt called valueForTime for the same value of time
repeatedly. First 6 times for 0 then 5 times for 40 and so on. But it
should be calling valueForTime for different value of time so that a
different value is returned and a different frame is drawn.

Forgive me if I am wrong somewhere.
--
Regards,
Parta



More information about the Qt-interest-old mailing list