Synchronization and asynchronous processing of QT signal-Slot

Source: Internet
Author: User

Connect is usually used. In fact, the last parameter uses the QT: autoconnection type: QT supports six connection modes, of which 3 is the most important:

1. QT: directconnection (direct connection mode) (the relationship between signals and slot functions is similar to function call and synchronous execution)

When the signal is sent, the corresponding slot function will be called immediately. The code after the emit statement is executed after all the slot functions are executed.

 

2. QT: queuedconnection (queuing method) (in this case, the signal is inserted into the signal queue. The relationship between the signal and the slot function is similar to message communication and is executed asynchronously)

After the signal is sent, It is queued to the signal queue. The signal is obtained only when the event loop of the thread to which the receiving object belongs obtains control, and the corresponding slot function is called. The code after the emit statement is executed immediately after the signal is sent, without waiting for the execution of the slot function to complete.

 

3. QT: autoconnection (automatic mode)

The default connection mode of QT. If the signal sending and receiving objects belong to the same thread, the working mode is the same as the direct connection mode; otherwise, the working mode is the same as the queuing mode.

 

If this parameter is not set, what is the default expression?

If this parameter is not added, the direct connection mode is the same: when the signal is sent, the corresponding slot function will be called immediately. The code after the emit statement is executed after all the slot functions are executed. In this thread, it is executed and synchronized sequentially, but it must be asynchronous with other threads. If multithreading is used, manual synchronization is still required.

Synchronization and asynchronous processing of QT signal-Slot

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.