开幕动画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();

 

©️2020 CSDN 皮肤主题: 代码科技 设计师:Amelia_0503 返回首页