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

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

【微服务架构】为故障设计微服务架构

Flink运行时架构 完整使用 (第四章)

【Enterprise Architecture】Agile and Enterprise Architecture: Strategic Alliance
![How to use [jmeter regular expression extractor] to solve the problem of returning the value as a parameter](/img/bf/2367304d5bdf520e369097a49a7bb6.png)
How to use [jmeter regular expression extractor] to solve the problem of returning the value as a parameter

浅析JWT安全问题

12 【其它组合式API】

Basic concepts, structures, and classes of thread pools

【系统设计】S3 对象存储

【 WeChat applet 】 read page navigation
随机推荐
Flink快速上手 完整使用 (第二章)
DAY25:逻辑漏洞复现
10 【异步组件 组合式函数(hooks)】
单例模式基类
乐观锁与悲观锁
以技术御风险,护航云原生 | 同创永益 X 博云举办产品联合发布会
I don't want to do accounting anymore, Die changed to a new one, moved forward bravely, and finally successfully passed the career change test to double his monthly salary~
Spotify expresses its architectural design using the C4 model
07 【动态组件 组件注册】
不要把公司当成家,被通知裁员时会变得不幸...
ARM Architecture 3: Addressing and Exception Handling of ARM Instructions
Flink部署 完整使用 (第三章)
OLTP and OLAP database architecture 】 【 : actual comparison
在“企业通讯录”的盲区,融云的边界与分寸
数据中台解决方案及未来发展方向
How to use [jmeter regular expression extractor] to solve the problem of returning the value as a parameter
对称加密与非对称加密的区别
[Data Architecture] Distributed Data Grid as a Solution for Centralized Data Monolith
Hugo NexT主题升级记录
BUUCTF problem solving PWN 】 【 record (4-6 pages continuously updated)