QTimeLine学习

来源:互联网 发布:js求二维数组的最大值 编辑:程序博客网 时间:2024/04/30 08:02

QTimeLine 是一个提供了控制动画的时间轴的类。通常都是通过调用槽函数来控制动画的显示。

         QTimeLine在构造函数中,你可以传递一个毫秒级的参数,设定动画的运行时间。如:

timeline1 = new QTimeLine(1000);

然后你可以设置该动画设置多少帧,如:

timeline1->setFrameRange(0,100);

这样表示动画分为100帧,然后每帧刷新的时候会产生一个信号,frameChanged(),这样,你就可以通过链接你的槽函数做你想做的事情:

connect(timeline1,SIGNAL(frameChanged(int)),SLOT(SLOTTimerMove1()));

最后一切准备就绪之后,调用start函数:

timeLine->start();

这样QTimeLine进入Running状态,并且每个一段时间发送一个frameChanged信号,这段时间间隔我们可以通过下面这个函数来设置:
timeline->setCurveShape(QTimeLine::LinearCurve);

函数的参数表示 信号frameChanged以线性的方式发送,当然还有其他的选项:

ConstantValueDescriptionQTimeLine::EaseInCurve0The value starts growing slowly, then increases in speed.先慢后快QTimeLine::EaseOutCurve1The value starts growing steadily, then ends slowly.先匀加速,后减速QTimeLine::EaseInOutCurve2The value starts growing slowly, then runs steadily, then grows slowly again.先慢,中间稳定,最后慢QTimeLine::LinearCurve3The value grows linearly (e.g., if the duration is 1000 ms, the value at time 500 ms is 0.5).匀速的QTimeLine::SineCurve4The value grows sinusoidally.正选曲线式QTimeLine::CosineCurve5The value grows cosinusoidally.余弦曲线式当动画结束时,QTimeLine进入 NotRunning 状态,同时发送finished()信号。当然你也可以随时调试stop()函数来结束动画。


本人写了一个小小的事例代码可供下载:http://download.csdn.net/detail/wswxfwps/6197397