当前位置:网站首页>属性动画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();
}
边栏推荐
猜你喜欢

Nvidia's gaming graphics card revenue plummets / Google data center explosion injures 3 people / iPhone battery percentage returns... More news today is here...

ARM体系结构2:处理器内核和汇编指令集

【元宇宙欧米说】听兔迷兔如何从虚拟到现实创造潮玩新时代

DAY26:GetShell专题

mySQL add, delete, modify and check advanced

初识Flink 完整使用 (第一章)

UE4 Sequence添加基础动画效果 (04-在序列中使用粒子效果)

【企业架构】敏捷与企业架构:战略联盟
![[System Design] S3 Object Storage](/img/62/0e3fef066b06ba83cadb406cfa075b.png)
[System Design] S3 Object Storage

shell之函数和数组
随机推荐
郭晶晶家的象棋私教,好家伙是个机器人
硬件工程师90天学习资料及笔记汇总
浅析JWT安全问题
地平线:面向规模化量产的智能驾驶系统和软件开发
【分布式】资源与事务:可观测性的基本二重性
【Enterprise Architecture】Agile and Enterprise Architecture: Strategic Alliance
PTA Exercise 2.2 Rotate an Array Left
Docker搭建Mysql一主一从
How to break the DeepFake face-changing scam?turn him over
DataStream API(基础篇) 完整使用 (第五章)
Basic concepts, structures, and classes of thread pools
mySQL add, delete, modify and check advanced
英伟达游戏显卡营收暴跌/ 谷歌数据中心爆炸致3人受伤/ iPhone电量百分比回归…今日更多新鲜事在此...
"Microservice Architecture" Arrangement and Choreography - Different Models for Making Systems Work Together
亚信AntDB数据库有啥业务应用场景和应用案例?
用高质量图像标注数据加速AI商业化落地
mySQL增删改查进阶
设计分享|基于单片机的从左到右流水灯
Spotify expresses its architectural design using the C4 model
UE4 Sequence添加基础动画效果 (05-蓝图触发Sequence)