QPropertyAnimation移动动画小Demo

来源:互联网 发布:粤语入门软件 编辑:程序博客网 时间:2024/05/16 17:34

先看看效果:



关键代码:
#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();