当前位置:网站首页>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 .
边栏推荐
- NBD Network Block Device
- 2.18 codeforces supplement
- How to combine multiple motion graphs into a GIF? Generate GIF animation pictures in three steps
- Common dynamic memory errors
- One code per day - day one
- Mining procedure processing
- Using Visual Studio
- basic_ String mind map
- BM setup process
- Power automatic test system nsat-8000, accurate, high-speed and reliable power test equipment
猜你喜欢

从408改考自主命题,211贵州大学考研改考

Position (5 ways)

JS to add elements to the header, or tail of an array

Arithmetic operations and expressions

Learning notes on February 18, 2022 (C language)

How to cut the size of a moving picture? Try this online photo cropping tool

【Try to Hack】vulnhub DC1

Judging the number of leap years from 1 to N years

Common dynamic memory errors

User defined data type - structure
随机推荐
One question per day,
分饼干问题
QQ情话糖果情话内容获取并保存
Std:: vector minutes
QT database connection deletion
Clipboard tutorial
Build a minimalist gb28181 gatekeeper and gateway server, establish AI reasoning and 3D service scenarios, and then open source code (I)
[C language] implementation of magic square array (the most complete)
Jaspersoft studio adding MySQL database configuration
System Verilog - thread
Installing QT plug-in in Visual Studio
Gif动画怎么在线制作?快试试这款gif在线制作工具
【中國海洋大學】考研初試複試資料分享
2. operator and expression multiple choice questions
Is it safe to open a stock account online?
Basic knowledge of pointer
【中国海洋大学】考研初试复试资料分享
The robot is playing an old DOS based game
搭建极简GB28181 网守和网关服务器,建立AI推理和3d服务场景,然后开源代码(一)
Master XSS completely from 0 to 1