Qt之QParallelAnimationGroup
2016-07-11 19:35
344 查看
简述
QParallelAnimationGroup类提供动画的并行组。QParallelAnimationGroup - 一个动画容器,当它启动的时候它里面的所有动画也启动,即:并行运行所有动画,当持续时间最长的动画完成时动画组也随之完成。
简述
详细描述
示例
效果
源码
更多参考
详细描述
QParallelAnimationGroup可以被当做任何其它的QAbstractAnimation动画,例如:暂停、重置、添加到其它动画组中。QParallelAnimationGroup *group = new QParallelAnimationGroup; group->addAnimation(anim1); group->addAnimation(anim2); group->start();
这个例子中,anim1、anim2是QPropertyAnimation。
示例
下面,我们通过QParallelAnimationGroup 来构建一个并行动画组,并添加属性动画QPropertyAnimation,这里也可以使用addAnimation()添加其它动画/动画组,就不予演示了。效果
源码
MainWindow::MainWindow(QWidget *parent) : CustomWindow(parent) { ... QPushButton *pStartButton = new QPushButton(this); pStartButton->setText(QString::fromLocal8Bit("开始动画")); QList<QLabel *> list; QStringList strList; strList << QString::fromLocal8Bit("一去丶二三里") << QString::fromLocal8Bit("青春不老,奋斗不止"); for (int i = 0; i < strList.count(); ++i) { QLabel *pLabel = new QLabel(this); pLabel->setText(strList.at(i)); pLabel->setAlignment(Qt::AlignCenter); pLabel->setStyleSheet("color: rgb(0, 160, 230);"); list.append(pLabel); } // 动画一 QPropertyAnimation *pAnimation1 = new QPropertyAnimation(list.at(0), "geometry"); pAnimation1->setDuration(1000); pAnimation1->setStartValue(QRect(0, 0, 100, 30)); pAnimation1->setEndValue(QRect(120, 130, 100, 30)); pAnimation1->setEasingCurve(QEasingCurve::OutBounce); // 动画二 QPropertyAnimation *pAnimation2 = new QPropertyAnimation(list.at(1), "geometry"); pAnimation2->setDuration(1000); pAnimation2->setStartValue(QRect(120, 130, 120, 30)); pAnimation2->setEndValue(QRect(170, 0, 120, 30)); pAnimation2->setEasingCurve(QEasingCurve::OutInCirc); m_pGroup = new QParallelAnimationGroup(this); // 添加动画 m_pGroup->addAnimation(pAnimation1); m_pGroup->addAnimation(pAnimation2); // 循环2次 m_pGroup->setLoopCount(2); connect(pStartButton, SIGNAL(clicked(bool)), this, SLOT(startAnimation())); ... } // 开始动画 void MainWindow::startAnimation() { m_pGroup->start(); }
更多参考
Qt之动画框架Qt之QPropertyAnimation
Qt之QSequentialAnimationGroup
Qt之QPauseAnimation
Qt之窗口动画(下坠、抖动、透明度)
相关文章推荐
- QT学习 第一章:基本对话框
- 使用Shiboken为C++和Qt库创建Python绑定
- Qt 5.6更新至RC版,最终版本近在咫尺
- Qt定时器和随机数详解
- Qt实现图片移动实例(图文教程)
- Qt for Android开发实例教程
- QModelIndex/Role/Model介紹<二>
- Qt Model/View/Delegate浅谈 - QAbstractListModel
- Qt Model/View/Delegate浅谈 - roleNames()
- QT历程(一):与CryptoJs对应的AES加密
- 基于PyQt5的快速开发框架QFramer
- OSX下安装PyQt
- ok6410开发板移植DirectFB手记
- 【笔记】给Qt内嵌一个Chrome吧
- 【算法】最短路径之A*搜索
- qt入门必备
- 在 Qt4 中使用 C++11
- Hello Word ~ v0.2.2 背单词软件发布 -- By WHYPRO
- ubuntu下opencv和qt的安装配置
- linux下opengl的安装(with qt)