QPropertyAnimation移动动画小Demo

先看看效果:

QPropertyAnimation移动动画小Demo


关键代码:
#include <QPropertyAnimation>


QPropertyAnimation *m_leftAnimation;
QPropertyAnimation *m_rightAnimation;

m_leftAnimation = new QPropertyAnimation(ui->lab_left,"pos");
m_rightAnimation  = new QPropertyAnimation(ui->lab_right,"pos");

int duration = 2000;
m_leftAnimation->setDuration(duration);
m_rightAnimation->setDuration(duration);
m_leftAnimation->setStartValue(QPoint(0,0));
m_leftAnimation->setEndValue(QPoint(-width/2,0));
m_rightAnimation->setStartValue(QPoint(width/2,0));
m_rightAnimation->setEndValue(QPoint(width,0));
m_leftAnimation->setEasingCurve(QEasingCurve::InOutCirc);
m_rightAnimation->setEasingCurve(QEasingCurve::InOutCirc);
m_leftAnimation->start();
m_rightAnimation->start();