Qt笔记_13
来源:互联网 发布:河南seo技术培训 编辑:程序博客网 时间:2024/05/16 09:03
动画框架
创建平滑的、具有动画效果的GUI界面
帮助关键字The Animation Framework;
使用QPropertyAnimation类
头文件 < QPropertyAnimation>
QApplication app(argc, argv); QPushButton button("Animated Button"); button.show(); QPropertyAnimation animation(&button, "geometry"); animation.setDuration(10000);// animation.setStartValue(QRect(0, 0, 120, 30));// animation.setEndValue(QRect(250, 250, 200, 60)); animation.setKeyValueAt(0, QRect(0, 0, 120, 30)); animation.setKeyValueAt(0.8, QRect(250, 250, 200, 60)); animation.setKeyValueAt(1, QRect(0, 0, 120, 30)); animation.start(); return app.exec();
动画中可以使用pause()来暂停动画;使用resume()结束暂停;使用stop()来停止动画;setDirection()设置动画方向;setLoopCount()设置动画重复次数。
使用缓和曲线
QEasingCurve::OutBounce缓和曲线。
实现弹跳效果:
QApplication app(argc, argv); QPushButton button("Animated Button"); button.show(); QPropertyAnimation animation(&button, "geometry"); animation.setDuration(2000); animation.setStartValue(QRect(250, 0, 120, 30)); animation.setEndValue(QRect(250, 300, 120, 30)); animation.setEasingCurve(QEasingCurve::OutBounce); animation.start(); return app.exec();
动画组
QParallelAnimationGroup并行动画组
QSequentialAnimationGroup串行动画组
QApplication app(argc, argv); QPushButton button1("Animated Button"); button1.show(); QPushButton button2("Animated Button2"); button2.show(); // 按钮部件1的动画 QPropertyAnimation *animation1 = new QPropertyAnimation(&button1, "geometry"); animation1->setDuration(2000); animation1->setStartValue(QRect(250, 0, 120, 30)); animation1->setEndValue(QRect(250, 300, 120, 30)); animation1->setEasingCurve(QEasingCurve::OutBounce); // 按钮部件2的动画 QPropertyAnimation *animation2 = new QPropertyAnimation(&button2, "geometry"); animation2->setDuration(2000); animation2->setStartValue(QRect(400, 300, 120, 30)); animation2->setEndValue(QRect(400, 300, 200, 60)); // 并行动画组 QParallelAnimationGroup group; group.addAnimation(animation1); group.addAnimation(animation2); group.start(); return app.exec();
阅读全文
0 0
- Qt笔记_13
- Java学习笔记_13
- 总结系列_13(Qt使用总结,续...)
- Qt学习之路_13(简易俄罗斯方块)
- 总结系列_13(Qt使用总结,续...)
- Qt学习之路_13(简易俄罗斯方块)
- JavaSE学习笔记_13:Java-System类
- HeadFirstC笔记_13 十大遗漏知识点
- qt_总结系列_13(Qt使用总结,续...)
- 7.3 qt_总结系列_13(Qt使用总结,续...)
- 151_13
- 工作总结_13
- 4_13
- TCP/IP网络编程 学习笔记_13 --基于I/O复用的服务端
- 机器学习&数据挖掘笔记_13(用htk完成简单的孤立词识别)
- [C++_13]异常
- 12_13总结
- 安卓基础_13
- JavaScript Good Articles
- 解决 MySQL server has gone away
- A Plug for UNIX 最大流简要变形
- Spark之获取GBT二分类函数的概率值
- 分别在IAR for STM32、IAR for STM8、MDK中重定向printf的方法
- Qt笔记_13
- 浅谈BI和大数据的关系
- 组合游戏/博弈论学习笔记
- 生活小记
- 小米运行时权限---代码中获取为granted,授权管理中显示为询问
- POJ 3692 二分图最大点独立集 解题报告
- java提高篇(43)--泛型
- 排序矩阵中的从小到大第k个数-LintCode
- HDU