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中的图像处理
第 1 章 基本的图像操作和处理 本章讲解操作和处理图像的基础知识,将通过大量示例介绍处理图像所需的 Python 工具包,并介绍用于读取图像.图像转换和缩放.计算导数.画图和保存结果等的基本工具.这 ...
- Windows中安装Scrapy
在linux中安装Scrapy只需要导入一些非python的支持包,在windows中安装Scrapy则是一波三折. 总之来说,主要分为以下几个步骤,可能由于系统问题(国内个人机子,甚至是小企业的机子 ...
- hadoop集群加入新节点hhbase调试
一.改动vi /etc/hosts 添加节点ip.(没个节点都要加入 ) 二.设置hostname vi /etc/sysconfig/network 把hostname改为nod ...
- 2、easyUI-创建 CRUD可编辑dataGrid(表格)
在介绍这节之前,我们先看一下效果图: 双击可以进入编辑
- Android开发:《Gradle Recipes for Android》阅读笔记(翻译)3.1——使用Build Types
问题: 你想要自定义debug和release的build types,并且新建一些新的types. 解决方案: 使用buildTypes块配置build types. 讨论: build type决 ...
- ZOJ1311(Network)
题目链接:传送门 题目大意:给你一副无向图,求有多少个割点 题目思路:tarjan算法(此题读入是字符串读入,需注意) #include <iostream> #include <c ...
- 【BZOJ2648】SJY摆棋子 KDtree
[BZOJ2648]SJY摆棋子 Description 这天,SJY显得无聊.在家自己玩.在一个棋盘上,有N个黑色棋子.他每次要么放到棋盘上一个黑色棋子,要么放上一个白色棋子,如果是白色棋子,他会找 ...
- mac安装以及删除mysql5.7
关于msyql5.7,安装时最大的改变就是有了一个默认密码 我安装的是mysql-5.7.17-macos10.12-x86_64.dmg 和mysql-workbench-community-6.3 ...
- PNG透明兼容IE6的几种方法
方法一:css方式,写一个属性hack,使用滤镜来解决png在ie6下不兼容的问题. _filter: progid:DXImageTransform.Microsoft.AlphaImageLoad ...
- linux linux 互传文件 win 不通过 ftp sftp 往linux 传文件(文件夹)
linux 传入 传出文件 swp port 22 怎样通过swp通过docker 容器向外传文件 通过scp Linux互传文件,需要知道文件源 file source 所在系统的ip wuse ...