QPropertyAnimation可以简单方便的实现对象的旋转和移动的动画效果。

1. 移动

Pixmap *item = new Pixmap(kineticPix);

QPropertyAnimation *animation = new QPropertyAnimation(item, "pos");
 anim1->setStartValue(QPoint(-100, -100));
 anim1->setEndValue(QPoint(500, 100));
 anim1->setEasingCurve(QEasingCurve::Linear);
 connect(anim1, SIGNAL(finished()), this, SLOT(EndAnimation())); //动画结束后需要执行的函数
 anim1->start(QAbstractAnimation::KeepWhenStopped);

2. 旋转

想要实现旋转的动画效果,要旋转的对象就必须支持‘’rotation‘’属性,否则无法实现旋转动画。需要在类中定义:

Q_PROPERTY(QPointF pos READ pos WRITE setPos)  //移动
  Q_PROPERTY(int rotation READ rotation WRITE setRotation) //旋转

然后同理处理旋转:
   QPropertyAnimation *animation = new QPropertyAnimation(item, "rotation");
   animation->setDuration(2000); 
   animation->setStartValue(0);
   animation->setEndValue(90);
   animation->setLoopCount(1); //旋转次数
   connect(animation, SIGNAL(finished()), this, SLOT(onAnimation()));
   animation->start(QAbstractAnimation::KeepWhenStopped);

最新文章

  1. (十)Maven依赖详解
  2. ca 自签名证书 并实现HAProxy https功能
  3. 想学习Android开发
  4. centos7 firewall 防火墙 命令
  5. 在你决定从事iOS开发前需要清楚的几个问题
  6. 【原】升级nginx注意点
  7. 1187: [HNOI2007]神奇游乐园 - BZOJ
  8. 【C语言】- 数据输出-printf( )和putchar( )
  9. Python 的格式化字符串format函数
  10. 支付宝openssl漏洞肆虐 互联网巨头称目前已修复
  11. javascript——处理(获取)浏览器版本、操作系统
  12. BZOJ 1024 生日快乐
  13. Failed to start SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse
  14. 用程序对hdfs进行操作。
  15. uva 11181 - Probability|Given
  16. 解决 bootstrap 在IE8下的兼容问题
  17. 高性能网站架构设计之缓存篇(1)- Redis C#客户端
  18. 对deep learning的第一周调研
  19. 【网络流】POJ1273 Drainage Ditches
  20. Javascript 精简语法介绍

热门文章

  1. iOS基础常用细节问题处理65条
  2. css文本样式-css学习之旅(4)
  3. Ubuntu 14 安装MySQL指南
  4. 证书,CSP与Openssl
  5. 滑动UITableViewCell出现多个按钮
  6. ExtJS:Grid数据导出至excel实例
  7. iOS多线程篇:NSThread简单介绍和使用
  8. 【53】java的多线程同步剖析
  9. hibernate链接数据库链接池c3p0配置
  10. Android 图片加载库Glide 实战(二),占位符,缓存,转换自签名高级实战