Qt开发动画
#include <QPropertyAnimation>
#include <QDesktopWidget>
//下坠
void MainWindow::on_pushButton_clicked()
{
QPropertyAnimation *pAnimation = new QPropertyAnimation(this, "geometry");
QDesktopWidget *pDesktopWidget = QApplication::desktop();
int x = (pDesktopWidget->availableGeometry().width() - width()) / 2;
int y = (pDesktopWidget->availableGeometry().height() - height()) / 2;
pAnimation->setDuration(1000);
pAnimation->setStartValue(QRect(x, 0, width(), height()));
pAnimation->setEndValue(QRect(x, y, width(), height()));
pAnimation->setEasingCurve(QEasingCurve::OutElastic);
pAnimation->start(QAbstractAnimation::DeleteWhenStopped);
}
//抖动
void MainWindow::on_pushButton_2_clicked()
{
QPropertyAnimation *pAnimation = new QPropertyAnimation(this, "pos");
pAnimation->setDuration(500);
pAnimation->setLoopCount(2);
pAnimation->setKeyValueAt(0, QPoint(geometry().x() - 3, geometry().y() - 3));
pAnimation->setKeyValueAt(0.1, QPoint(geometry().x() + 6, geometry().y() + 6));
pAnimation->setKeyValueAt(0.2, QPoint(geometry().x() - 6, geometry().y() + 6));
pAnimation->setKeyValueAt(0.3, QPoint(geometry().x() + 6, geometry().y() - 6));
pAnimation->setKeyValueAt(0.4, QPoint(geometry().x() - 6, geometry().y() - 6));
pAnimation->setKeyValueAt(0.5, QPoint(geometry().x() + 6, geometry().y() + 6));
pAnimation->setKeyValueAt(0.6, QPoint(geometry().x() - 6, geometry().y() + 6));
pAnimation->setKeyValueAt(0.7, QPoint(geometry().x() + 6, geometry().y() - 6));
pAnimation->setKeyValueAt(0.8, QPoint(geometry().x() - 6, geometry().y() - 6));
pAnimation->setKeyValueAt(0.9, QPoint(geometry().x() + 6, geometry().y() + 6));
pAnimation->setKeyValueAt(1, QPoint(geometry().x() - 3, geometry().y() - 3));
pAnimation->start(QAbstractAnimation::DeleteWhenStopped);
}
//透明度变化
void MainWindow::on_pushButton_3_clicked()
{
QPropertyAnimation *pAnimation = new QPropertyAnimation(this, "windowOpacity");
pAnimation->setDuration(1000);
pAnimation->setKeyValueAt(0, 1);
pAnimation->setKeyValueAt(0.5, 0);
pAnimation->setKeyValueAt(1, 1);
pAnimation->start(QAbstractAnimation::DeleteWhenStopped);
}
转自:http://blog.csdn.net/liang19890820/article/details/51888114
//逐渐出现
QPropertyAnimation *animation = new QPropertyAnimation(this, "windowOpacity");
animation->setDuration(1000);
animation->setStartValue(0);
animation->setEndValue(1);
animation->start();
以上均为窗口动画。
控件动画:【均未成功,不知为何】
1、
QPropertyAnimation *pAnimation = new QPropertyAnimation(ui.groupBox, "opacity");
pAnimation->setDuration(1000);
pAnimation->setStartValue(0);
pAnimation->setEndValue(1);
pAnimation->start(QAbstractAnimation::DeleteWhenStopped);
2、
QGraphicsOpacityEffect* effect = new QGraphicsOpacityEffect(ui.label);
effect->setOpacity(1);
ui.label->setGraphicsEffect(effect);
QPropertyAnimation *pAnimation = new QPropertyAnimation(effect, "opacity",this);
pAnimation->setEasingCurve(QEasingCurve::Linear);
pAnimation->setDuration(10000);
pAnimation->setStartValue(1);
pAnimation->setEndValue(0);
pAnimation->start(QAbstractAnimation::KeepWhenStopped);
delete effect;
delete pAnimation;
Qt开发动画的更多相关文章
- Qt开发技术:QCharts(三)QCharts样条曲线图介绍、Demo以及代码详解
若该文为原创文章,未经允许不得转载原博主博客地址:https://blog.csdn.net/qq21497936原博主博客导航:https://blog.csdn.net/qq21497936/ar ...
- Qt开发Activex笔记(一):环境搭建、基础开发流程和演示Demo
前言 使用C#开发动画,绘图性能跟不上,更换方案使用Qt开发Qt的控件制作成OCX以供C#调用,而activex则是ocx的更高级形式. QtCreator是没有Active控件项目的,所有需要 ...
- win使用MSYS2安装Qt开发环境
原文链接 MSYS2 下载地址: pacman的具体用法 有pacman的具体使用方法.我们首先对系统升级 我们首先对系统升级 pacman -Syu 就会检测整个系统可以升级的组件,并自动下载安装, ...
- qt 窗口动画
窗口动画 编辑删除转载 2015-10-10 14:50:27 标签:qt渐变动画 一个应用程序通常包含多个动画,例如,你可能希望同时移动许多graphic items或者一个个按照串行的方式的移动他 ...
- 细数Qt开发的各种坑(欢迎围观)
1:Qt的版本多到你数都数不清,多到你开始怀疑人生.从4.6开始到5.8,从MSVC编译器到MINGW编译器,从32位到64位,从Windows到Linux到MAC.MSVC版本还必须安装对应的VS2 ...
- 用Qt开发第一个Hello World程序
配置好Qt的环境变量之后,我们才可以进行下面的通过终端来使用Qt开发这个第一个程序 因为Qt的文件路径不能有中文否则会报错,所以一般都把工程文件都建立在根目录 我们创建的Qt程序包含两个部分:1.GU ...
- Qt之动画框架
简述 Qt动画框架旨在为创建动画和平滑的GUI提供了一种简单的方法.通过Qt动画属性,该框架为部件和其它QObject对象的动画操作提供了非常大的自由性,框架也可以被用于图形视图框架中,动画框架中许多 ...
- 第一章 搭建Qt开发环境
第一章 搭建Qt开发环境 1.到http://download.qt-project.org/archive/上下载Qt的源码包.我下载的是qt-everywhere-opensource-src-4 ...
- Ubuntu 12.04下搭建Qt开发环境
http://download.qt.io/official_releases/qt/ Ubuntu 环境下Gtk与Qt编译环境安装与配置(系统环境是Ubuntu 12.04) 1.配置基础开发环境G ...
随机推荐
- Python gevent学习笔记-2
在上一篇里面介绍了gevent的最主要的功能,先来来了解一下gevent里面一些更加高级的功能. 事件 事件是一种可以让greenlet进行异步通信的手段. ? 1 2 3 4 5 6 7 8 9 1 ...
- Python简单的线程池
class ThreadPool(object): def __init__(self, max_num=20): # 创建一个队列,队列里最多只能有10个数据 self.queue = queue. ...
- SAP ABAP 常见系统变量
因为版权的问题,纯手工打,且行且珍惜. SY-PAGEO 当前页号 SY-LSIND 列表索引页 SY-DATUM 当前日期 SY-UZEIT 当前时间 SY-LISTI 上一个列表的索引 SY-L ...
- How to convert BigDecimal to Double in spring-data-mongodb framework
问题描述:我们都知道对于涉及钱的数据必须使用BigDecimal类型进行存储,今天在查询mongo时仍然有精度问题,虽然我在代码中使用了Big Decimal类型,但mongo中使用的是double类 ...
- 当公有云Azure拥抱Docker容器技术
本文转载至 http://3387405.blog.51cto.com/3377405/1598977 预见未来看似是一件不太可能的事情,然而现在企业科技高速发展的态势完全超乎想象. 就在几周前Inf ...
- UIAlertController custom font, size, color
本文转载至 http://stackoverflow.com/questions/26460706/uialertcontroller-custom-font-size-color up vote2d ...
- E - Rails (栈)
E - Rails Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Description The ...
- Sublime Text 3如何快速生成HTML5的头部信息和常用的快捷键
一.快速生成HTML5的头部信息的步骤: 1.Ctrl + N,新建一个文档: 2.Ctrl + Shift + P,打开命令模式,再输入 sshtml 进行模糊匹配,将语法切换到html模式: 3. ...
- 《挑战程序设计竞赛》1.6 轻松热身 POJ1852
Ants Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 12782 Accepted: 5596 Description ...
- KVC && KVO 初见
Look,这是一个很简单的要求,点击Add me,age +1. 想一想的话很简单的,设置一个属性Nsinteger age,点击button add me,直接加1在重新显示Lable就好啦,不过, ...