当前位置:网站首页>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 .
边栏推荐
- 15 -- 最接近原点的 K 个点
- User defined data type - structure
- Disable scrolling in the iPhone web app- Disable scrolling in an iPhone web application?
- JS to add elements to the header, or tail of an array
- Qt: Pro project file
- Source code analysis of synergetics and ntyco
- About the problem of kicad stuck in win10 version, version 6 x
- Cross compilation correlation of curl Library
- Source code analysis of zeromq lockless queue
- Learning notes on February 5, 2022 (C language)
猜你喜欢

Learning notes on February 5, 2022 (C language)

有哪个瞬间让你觉得这个世界出bug了?

电源自动测试系统NSAT-8000,精准高速可靠的电源测试设备

多张动图怎样合成一张gif?仅需三步快速生成gif动画图片

semget No space left on device

Judging the number of leap years from 1 to N years

Open a restaurant

Sequential programming 1

User defined data type - structure

Js- get the mouse coordinates and follow them
随机推荐
Custom structure type
High precision addition
QT inline dialog
Master XSS completely from 0 to 1
Usage of pure virtual functions
System Verilog — interface
2. operator and expression multiple choice questions
Daily question, Caesar code,
【中國海洋大學】考研初試複試資料分享
SPARQL learning notes of query, an rrdf query language
RDB and AOF persistence of redis
1090.Phone List
Qlogsystem log system configuration use
[try to hack] vulhub shooting range construction
Is it normal to dig for money? Is it safe to open a stock account?
Is it safe to open a stock account online?
QT opens the print dialog box in a text editor
From 408 to independent proposition, 211 to postgraduate entrance examination of Guizhou University
QT database connection
AB string interchange