当前位置:网站首页>5 connection modes of QT signal slot
5 connection modes of QT signal slot
2022-06-25 15:06:00 【Knowledge first】
qt The connection mode defined by the source code is as follows :
1、Qt::AutoConnection
Generally, the fifth parameter cannot be written , In fact, the default value used , Using this value, the connection type will be determined during signal transmission .
- If the receiver and sender are in the same thread , Then automatically use Qt::DirectConnection type .
- If the receiver and sender are not in the same thread , Then automatically use Qt::QueuedConnection type .
2、Qt::DirectConnection
The slot function will be called directly when the signal is sent , The slot function runs on the thread where the signal sender is located , It's kind of like a callback function .
The effect looks like calling the slot function directly at the signal sending position . This is dangerous in a multithreaded environment , May cause a run down .
3、Qt::QueuedConnection:
The slot function is called when it controls the event loop back to the recipient's thread , The slot function runs on the thread where the signal receiver is located .
After sending the signal , The slot function will not be called immediately , Wait until the receiver's current function is executed , After entering the event loop , The slot function will be called . This is generally used in multithreaded environments .
4、Qt::BlockingQueuedConnection
The call timing of the slot function is the same as Qt::QueuedConnection Agreement , However, after sending the signal, the sender's thread will block , Until the slot function runs .
Use this connection method , The receiver and sender must not be in the same thread , Otherwise the program will deadlock !!! This may be required when synchronization is required between multiple threads .
5、Qt::UniqueConnection
This flag It can be done by biting or (|) Used in combination with the above four . When this flag When setting , When a signal is connected to a slot , Repeated connections will fail . That is to avoid repeated connections .
I always thought UniqueConnection Should not be of connection type , It belongs to the connection property .
边栏推荐
- 2022年广东高考分数线出炉,一个几家欢喜几家愁
- Stderr and stdout related standard outputs and other C system APIs
- 90 后眼中的理想 L9:最简单的产品哲学,造最猛的爆款 | 指南斟
- 【中国海洋大学】考研初试复试资料分享
- [C language] 32 keyword memory skills
- The difference between sizeof and strlen
- iconv_ Open returns error code 22
- Qmake uses toplevel or topbuilddir
- One question per day, punch in
- Source code analysis of synergetics and ntyco
猜你喜欢

Design and implementation of timer

【Try to Hack】vulhub靶场搭建

Common dynamic memory errors

Jaspersoft studio adding MySQL database configuration
![[Ocean University of China] information sharing for the first and second examinations of postgraduate entrance examination](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[Ocean University of China] information sharing for the first and second examinations of postgraduate entrance examination

QT loading third-party library basic operation

Yolov3 spp Darknet version to caffemodel and then to OM model

【Try to Hack】vulnhub DC1

弹性布局(display:flex;)属性详解

How to crop GIF dynamic graph? Take this picture online clipping tool
随机推荐
从0到1完全掌握 XSS
One question per day, punch in
从408改考自主命题,211贵州大学考研改考
Iterator failure condition
Jaspersoft studio installation
p1408
QT database connection
For the first time in China, Chinatelecom 5g underground personnel positioning project is officially commercial: it can track the position in real time to ensure operation safety
How to cut the size of a moving picture? Try this online photo cropping tool
Generation method and usage of coredump
[try to hack] vulhub shooting range construction
Single user mode
Source code analysis of synergetics and ntyco
[Ocean University of China] Data Sharing for retest of initial Examination
Position (5 ways)
System Verilog — interface
挖财是正规的吗?股票开户安全吗?
JS select all exercise
SPARQL learning notes of query, an rrdf query language
Stack and queue