当前位置:网站首页>QT interface optimization: double click effect
QT interface optimization: double click effect
2022-04-23 14:27:00 【Spiritual health】
Qt Interface optimization : Double click the mouse effect
List of articles
One 、 Double click special effects
Two 、 Use steps
1. .h part
The code is as follows :
#include <QMovie>
#include <QLabel>
#include <QMouseEvent>
#include <QLine>
protected:
void mouseDoubleClickEvent(QMouseEvent *event); // Double click event
2. .cpp part
The code is as follows :
// Double click the mouse effect
void MainWindows::mouseDoubleClickEvent(QMouseEvent *event)
{
// Judge whether it is double clicking with the left mouse button
if(event->button() == Qt::LeftButton)
{
QLabel * label = new QLabel(this);
QMovie * movie = new QMovie("://images/mouse.gif");// load gif picture
// Set up label Automatic adaptation gif Size
label->setScaledContents(true);
label->setMovie(movie);
// Here to call move convenient , Conduct resize, What we need to know is gif The size of is 150*150
label->resize(180,180);
label->setStyleSheet("background-color:rgba(0,0,0,0);");
// Set mouse penetration
label->setAttribute(Qt::WA_TransparentForMouseEvents, true);
// Give Way label The center of the is at the double click position of the current mouse
label->move(event->pos().x()-label->width()/2,event->pos().y()-label->height()/2);
// Start playing gif
movie->start();
label->show();
// binding QMovie The signal of , Judge gif plays
connect(movie, &QMovie::frameChanged, [=](int frameNumber) {
if (frameNumber == movie->frameCount() - 1)//gif The number of plays is 1, Turn off the tag
label->close();
});
}
}
Be careful
gif The background of the moving picture must be transparent !!!
The following is my mouse double click effect picture , You can click the picture , Long press to save and use .
版权声明
本文为[Spiritual health]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231411423135.html
边栏推荐
- 浅谈skiplist在LevelDB的应用
- ssh限制登录的四种手段
- Use cases of the arrays class
- Multisim Simulation Design of DC adjustable regulated power supply of LM317 (with simulation + paper + reference)
- MySQL同步Could not find first log file name in binary log index file错误
- 555定时器+74系列芯片搭建八路抢答器,30s倒计时,附Proteus仿真等
- Five ways of using synchronized to remove clouds and fog are introduced
- Detailed explanation of SAR command
- man man随记和crontab的@reboot用法
- Upgrade of openssh and modification of version number
猜你喜欢
Notes on Visio drawing topology
基于TLC5615的多路可调数控直流稳压电源,51单片机,含Proteus仿真和C代码等
Eight way responder system 51 Single Chip Microcomputer Design [with Proteus simulation, C program, schematic diagram, PCB files, component list and papers, etc.]
C语言知识点精细详解——初识C语言【1】——你不能不知的VS2022调试技巧及代码实操【1】
AT89C51 MCU digital voltmeter development, measuring range 0 ~ 5V, proteus simulation, schematic diagram, PCB and C program, etc
SHT11传感器的温度湿度监控报警系统单片机Proteus设计(附仿真+论文+程序等)
Tongxin UOS php7 2.3 upgrade to php7.0 two point two four
I thought I could lie down and enter Huawei, but I was confused when I received JD / didi / iqiyi offers one after another
AT89C52 MCU frequency meter (1Hz ~ 20MHz) design, LCD1602 display, including simulation, schematic diagram, PCB and code, etc
Use the executors class to quickly create a thread pool
随机推荐
51 MCU + LCD12864 LCD Tetris game, proteus simulation, ad schematic diagram, code, thesis, etc
I thought I could lie down and enter Huawei, but I was confused when I received JD / didi / iqiyi offers one after another
51单片机的花卉、农田自动浇水灌溉系统开发,Proteus仿真,原理图和C代码
API Gateway/API 网关(二) - Kong的使用 - 负载均衡Loadbalance
C语言知识点精细详解——初识C语言【1】
关于在vs中使用scanf不安全的问题
Upgrade of openssh and modification of version number
Branch statement of process control
错误:无法远程查找到密钥 “428F7ECC7117F726“
js 进度条,显示加载进度
C语言知识点精细详解——数据类型和变量【2】——整型变量与常量【1】
redis的五种数据类型
Proteus simulation design of DC adjustable regulated power supply (with simulation + paper and other data)
MySQL同步Could not find first log file name in binary log index file错误
JS format time
Tongxin UOS php7 2.3 upgrade to php7.0 two point two four
API Gateway/API 网关(三) - Kong的使用 - 限流rate limiting(redis)
进入新公司,运维工程师从下面这几项了解系统的部署
Flop effect
OpenSSH的升级、版本号的修改