当前位置:网站首页>QT animation loading and closing window
QT animation loading and closing window
2022-06-25 15:07:00 【Knowledge first】
Realization effect
Design thinking
utilize qt Animation class of , Realize the moving animation of the window .
Load window , First create a window and then display , Then set the animation start point and end point , You can move and load the window ; Close the window and perform the opposite operation .
Code implementation
The following code pairs OverviewWindow Window to achieve animation loading and closing .
#include "overviewwindow.h"
#include <QApplication>
#include <QDesktopWidget>
#include <QRect>
OverviewWindow *overview = new OverviewWindow(this);
overview->show();
// Load the animation of the window
QPropertyAnimation *pAnimation = new QPropertyAnimation(overview,"geometry",this);
pAnimation->setDuration(1000);
pAnimation->setEasingCurve(QEasingCurve::OutBounce);
pAnimation->setStartValue(QRect(this->x(),this->y()
,overview->width(),overview->height()));
QDesktopWidget *desktop = QApplication::desktop();
pAnimation->setEndValue(QRect((desktop->width()-this->width())/2
,(desktop->height()-this->height())/2
,overview->width()
,overview->height()));
pAnimation->start();
connect(overview,&OverviewWindow::closeThis,this,[=]()
{
// Close window animation
pAnimation->setEasingCurve(QEasingCurve::InQuart);
QDesktopWidget *desktop = QApplication::desktop();
pAnimation->setStartValue(QRect((desktop->width()-this->width())/2
,(desktop->height()-this->height())/2
,overview->width()
,overview->height()));
pAnimation->setEndValue(QRect(this->x(),this->y()
,overview->width(),overview->height()));
pAnimation->start();
connect(pAnimation,&QPropertyAnimation::finished,[=]{
delete overview;
delete pAnimation;
});
});
边栏推荐
- AB string interchange
- Luogu p5707 [deep foundation 2. example 12] late for school
- Usage of pure virtual functions
- Position (5 ways)
- basic_ String mind map
- [C language] 32 keyword memory skills
- Gif动图如何裁剪?收下这个图片在线裁剪工具
- Character encoding minutes
- Go closure usage example
- [C language] implementation of magic square array (the most complete)
猜你喜欢
Ideal L9 in the eyes of the post-90s: the simplest product philosophy, creating the most popular products
Mining procedure processing
【中國海洋大學】考研初試複試資料分享
Add the resources directory under test in idea
【Try to Hack】vulnhub DC1
如何裁剪动图大小?试试这个在线照片裁剪工具
[try to hack] vulhub shooting range construction
How to cut the size of a moving picture? Try this online photo cropping tool
‘make_ unique’ is not a member of ‘std’
Position (5 ways)
随机推荐
Dynamic memory allocation
Vs2019 scanf error
In 2022, the score line of Guangdong college entrance examination was released, and several families were happy and several worried
分饼干问题
GDB debugging
A deformation problem of Hanoi Tower
Boost listening port server
Compile Caffe's project using cmake
Position (5 ways)
电源自动测试系统NSAT-8000,精准高速可靠的电源测试设备
Ideal L9 in the eyes of the post-90s: the simplest product philosophy, creating the most popular products
Modal and modeless dialogs for QT
dev/mapper的解释
Breakpad usage and DMP analysis
If multiple signals point to the same slot function, you want to know which signal is triggered.
Usage of pure virtual functions
QT database connection deletion
Luogu p5707 [deep foundation 2. example 12] late for school
[deep learning] multi label learning
15 -- k points closest to the origin