您的位置:首页 > 运维架构

QPropertyAnimation移动动画小Demo

2017-08-11 14:10 183 查看
先看看效果:



关键代码:

#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();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: