先看看效果:

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();


相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-08
猜你喜欢
  • 2022-12-23
  • 2021-10-20
  • 2021-11-20
  • 2022-12-23
  • 2021-11-05
相关资源
相似解决方案