当前位置:网站首页>属性动画QPropertyAnimation
属性动画QPropertyAnimation
2022-08-10 09:26:00 【Lee Neo】
widget.h
#include "widget.h"
#include "ui_widget.h"
#include <QGraphicsColorizeEffect>
#include <QGraphicsOpacityEffect>
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
propertyAnimation = new QPropertyAnimation(ui->geometryWidget,"geometry");
//设置动画起始值、关键值、终止值;
propertyAnimation->setStartValue(QRect(0,0,100,100));
propertyAnimation->setKeyValueAt(0.5,QRect(0,400,200,200));
propertyAnimation->setEndValue(QRect(600,400,200,200));
//设置动画时常;
propertyAnimation->setDuration(2000);
//设置动画循环周期;
propertyAnimation->setLoopCount(1);
//设置动画缓和曲线;动画运动速度曲线;
propertyAnimation->setEasingCurve(QEasingCurve::InOutCubic);
//设置颜色动画;
QGraphicsColorizeEffect *graphicsColorizeEffect = new QGraphicsColorizeEffect(this);
ui->colorWidget->setGraphicsEffect(graphicsColorizeEffect);
propertyAnimation1 = new QPropertyAnimation(graphicsColorizeEffect,"color");
propertyAnimation1->setStartValue(QColor(Qt::black));
propertyAnimation1->setEndValue(QColor(Qt::red));
propertyAnimation1->setDuration(4000);
//不透明度动画
QGraphicsOpacityEffect *graphicsOpacityEffect = new QGraphicsOpacityEffect(this);
ui->colorWidget->setGraphicsEffect(graphicsOpacityEffect);
propertyAnimation2 = new QPropertyAnimation(graphicsOpacityEffect,"opacity");
propertyAnimation2->setStartValue(0.0);
propertyAnimation2->setEndValue(1.0);
propertyAnimation2->setDuration(2000);
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_pushButton_clicked()
{
propertyAnimation->start();
propertyAnimation2->start();
}
void Widget::on_pushButton_2_clicked()
{
propertyAnimation1->start();
}
边栏推荐
- npm i安装报错
- [OAuth2] Nineteen, OpenID Connect dynamic client registration
- J9 Number Theory: Macro Analysis of DAO Characteristics
- 【API Management】What is API Management and why is it important?
- UE4 粒子特效基础学习 (01-将粒子效果挂载到角色身上)
- The first offline workshop in 2022!Data application experience day for application developers is coming | TiDB Workshop Day
- 浅谈DAO+DeFi+NFT模式开发代码技术方案丨链游元宇宙NFT盲盒项目技术开发逻辑(源码程序)
- 刷题工具h
- js读取excel时间格式转换
- shell iterates over folders and outputs
猜你喜欢

凭借这份阿里架构师的万字面试手册,逆风翻盘,斩获阿里offer

J9 Digital Theory: What kind of sparks will Web3.0+ Internet e-commerce cause?
![[OAuth2] Nineteen, OpenID Connect dynamic client registration](/img/01/2f318a06e130cc222aa1736abbd152.png)
[OAuth2] Nineteen, OpenID Connect dynamic client registration

mySQL add, delete, modify and check advanced

00后女孩月薪3200,3年买两套房,这个程序员变现新风口千万要把握住

PTA 习题2.2 数组循环左移

2022年固定资产管理系统的概况

线程池的基本概念、结构、类

MySQL的用户临时表与内部临时表

微信小程序--》小程序生命周期和WXS使用
随机推荐
关于镜像源的一些记录
BUUCTF problem solving PWN 】 【 record (4-6 pages continuously updated)
Controller层代码这么写,简洁又优雅!
【元宇宙欧米说】看UCOUCO如何将行为艺术融入元宇宙
浅析JWT安全问题
【REST架构】OData、JsonAPI、GraphQL 有什么区别?
Optimistic and pessimistic locking
10 【异步组件 组合式函数(hooks)】
BUUCTF【pwn】解题记录(4-6页持续更新中)
打工人的第27天-平凡但不平淡的日子
IDEA中xml文件头报错:URI is not registered (Settings | Languages & Frameworks | Schemas and DTDs)
Oracle rac所在的网络要割接,停掉其中一个rac节点,这种方案可行吗?
win下的开发环境变量记录
J9数字论:关于DAO 特点的宏观分析
傅立叶级数与傅里叶变换
原型和原型链
用高质量图像标注数据加速AI商业化落地
郭晶晶家的象棋私教,好家伙是个机器人
MUDA:对齐特定域的分布和分类器以实现来自多源域的跨域分类
设计分享|基于单片机的从左到右流水灯