当前位置:网站首页>属性动画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();
}
边栏推荐
- Guo Jingjing's personal chess teaching, the good guy is a robot
- BUUCTF problem solving PWN 】 【 record (4-6 pages continuously updated)
- How to understand the difference between BIO, NIO, and AIO
- 微信小程序--》小程序生命周期和WXS使用
- 硬件工程师90天学习资料及笔记汇总
- DAY25: Logic Vulnerability
- Flink部署 完整使用 (第三章)
- Optimistic and pessimistic locking
- 【微信小程序】一文读懂页面导航
- Spotify使用C4模型表达其架构设计
猜你喜欢
10 【异步组件 组合式函数(hooks)】
DataStream API(基础篇) 完整使用 (第五章)
FPGA中BEL Site Tile FSR SLR分别指什么?
Flink运行时架构 完整使用 (第四章)
Vivado时序约束中Tcl命令的对象及属性
Spotify使用C4模型表达其架构设计
J9 Digital Theory: What kind of sparks will Web3.0+ Internet e-commerce cause?
CAD to WPF: Tips on converting CAD drawing files to WPF vector code files (xaml files)
12 【其它组合式API】
浅谈DAO+DeFi+NFT模式开发代码技术方案丨链游元宇宙NFT盲盒项目技术开发逻辑(源码程序)
随机推荐
qrcode-----生成二维码
13 【script setup 总结】
FPGA时钟篇(三) MRCC和SRCC的区别
DAY25: Logic vulnerability recurrence
Basic concepts of concurrency, operations, containers
浅谈DAO+DeFi+NFT模式开发代码技术方案丨链游元宇宙NFT盲盒项目技术开发逻辑(源码程序)
1 活动时间与安排
刷题工具h
Nvidia's gaming graphics card revenue plummets / Google data center explosion injures 3 people / iPhone battery percentage returns... More news today is here...
DAY26:GetShell专题
人
FPGA中BEL Site Tile FSR SLR分别指什么?
07 【动态组件 组件注册】
浅析JWT安全问题
硬件工程师90天学习资料及笔记汇总
J9数字论:关于DAO 特点的宏观分析
Defending risks with technology and escorting cloud native | Tongchuang Yongyi X Boyun held a joint product launch conference
重学冒泡排序
【微信小程序】一文读懂页面导航
DAY25:逻辑漏洞复现