当前位置:网站首页>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
边栏推荐
- Processing MKDIR: unable to create directory 'AAA': read only file system
- Qt实战:云曦日历篇
- 逻辑卷创建与扩容
- 1 minute to understand the execution process and permanently master the for cycle (with for cycle cases)
- 51 MCU + LCD12864 LCD Tetris game, proteus simulation, ad schematic diagram, code, thesis, etc
- C语言知识点精细详解——数据类型和变量【1】——进位计数制
- Redis源码分析之HSET流程与ziplist
- source insight via samba
- LotusDB 设计与实现—1 基本概念
- IE8 browser prompts whether to block access to JS script
猜你喜欢

AT89C52单片机的频率计(1HZ~20MHZ)设计,LCD1602显示,含仿真、原理图、PCB与代码等

On the insecurity of using scanf in VS

API Gateway/API 网关(三) - Kong的使用 - 限流rate limiting(redis)

AT89C51单片机的数字电压表开发,量程0~5V,proteus仿真,原理图PCB和C程序等

Multisim Simulation Design of DC adjustable regulated power supply of LM317 (with simulation + paper + reference)

Qt实战:云曦聊天室篇

Tongxin UOS php7 2.3 upgrade to php7.0 two point two four

四层和八层电梯控制系统Proteus仿真设计,51单片机,附仿真和Keil C代码

Design of single chip microcomputer Proteus for temperature and humidity monitoring and alarm system of SHT11 sensor (with simulation + paper + program, etc.)

x509证书cer格式转pem格式
随机推荐
翻牌效果
LM317的直流可调稳压电源Multisim仿真设计(附仿真+论文+参考资料)
Docker (V) MySQL installation
Five ways of using synchronized to remove clouds and fog are introduced
KVM learning resources
AT89C51 MCU digital voltmeter development, measuring range 0 ~ 5V, proteus simulation, schematic diagram, PCB and C program, etc
Quickly understand the three ways of thread implementation
Thread group ThreadGroup uses introduction + custom thread factory class to implement threadfactory interface
MQ-2和DS18B20的火灾温度-烟雾报警系统设计,51单片机,附仿真、C代码、原理图和PCB等
555 timer + 74 series chip to build eight way responder, 30s countdown, proteus simulation, etc
浅谈skiplist在LevelDB的应用
Use the executors class to quickly create a thread pool
KVM学习资源
Redis源码分析之HSET流程与ziplist
八路抢答器系统51单片机设计【附Proteus仿真、C程序、原理图及PCB文件、元器件清单和论文等】
xx项目架构随记
统信UOS PHP7.2.3升级至PHP7.2.24
Matrix exchange row and column
Some little records~
Proteus simulation design of DC adjustable regulated power supply (with simulation + paper and other data)