[注:详细介绍可以向下翻阅查看]
该类关联的头文件:#include
该类的父类是:QVarianAnimation
这个类始创于 QtCore 4.6 版本
保护函数1:事件函数
virtual bool event(QEvent * event)
保护函数2:更新值域
virtual void updateCurrentValue(const QVariant & value)
保护函数3:更新状态
virtual void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
这是一个源自 Qt 的动画效果类
QPropertyAnimation 插入 Qt 的属性,将属性保存在 QVariants 当中,
QPropertyAnimation interpolates over Qt properties. As property values are stored in QVariants,
QPropertyAnimation 继承自 QVariantAnimation, 支持父类的动画效果成为了超级类.
the class inheritsQVariantAnimation, and supports animation of the same meta types as its super class.
窗口部件必须是继承自 QObject, 这是实现动画效果的基本条件.
A class declaring properties must be a QObject. To make it possible to animate a property,
它一定要提供一个控制对象(当然, QPropertyAnimation 本身 也可以成为这个属性值),这样才可以使窗口部件实现动画的效果.
it must provide a setter(so that QPropertyAnimation can set the property's value). Note that this makes it possible to animate many of Qt's widgets.
让我们看一个简单的示例:
Let's look at an example:
QPropertyAnimation *animation = new QPropertyAnimation(myWidget, "geometry");
animation->setDuration(10000);
animation->setStartValue(QRect(0, 0, 100, 30));
animation->setEndValue(QRect(250, 250, 100, 30));
animation->start();
属性名和窗口部件对象,应该是通过构造函数传给动画类的.
the property name and the QObject instance of which property should be animated are passed to the constructor.
构造函数执行完毕之后,你就可以明确的给出开始和结束的QRect属性.
You can then specify the start and end value of the property.
动画的执行过程与类中的属性相关联,动画效果由你的类来实现.
The procedure is equal for properties in classes you have implemented yourself
只要确认好你的 QVariantAnimation 和你的 QVariant 即可.
just check with QVariantAnimation that your QVariant type is supported.
QVarianAnimation类介绍了如何建立一个动画.
The QVarianAnimation class description explains how to set up the animation in detail.
要注意的是,如果没有设置一个起始的坐标值,属性会将当前窗口控件创建的值,作为起始值.Note, however, that if a start value is not set, the property will start at the value it had when the QPropertyAnimation instance was created.
QPropertyAnimation 有自己的魅力.
QPropertyAnimation works like a charm on its own,
相对于复杂的动画例如:包含多个窗口部件对象的,规定使用 QAnimationGroup 类
For complex animations that. for instance.contain several objects, QAnimationGroup is provided.
QAnimationGroup 是包含多个动画的动画组
An animation group is an animation that can contain other animations.
可以在任何时候管理各个动画的播放.
and that can manage when its animations are played.
可以查阅在 QParallelAnimationGroup 里的例子.
Look at QParallelAnimationGroup for an example.
也可以查阅 QVarianAnimation QAnimationGroup 等动画框架.
See also QVarianAnimation, QAnimationGroup, and The Animation Framework.