Tips for using signals and slots in QT

Source: Internet
Author: User
Tags emit

Typical mechanism in signal (Signal) and slot (slot)-QT

This article is very detailed, it is not repeated here, only a little bit in the actual use of problems that may be encountered.

1. One signal does not connect several slot functions at the same time, otherwise the order of execution is random, and the final result may differ from what you expect.

2. Basically, after all the signals are connected to the slot function, the slot function of the current connection is executed and then the content after the emit signal is executed. However, there will be an unexpected situation: if the current signal inside the content to be executed is too complex (e.g.slots contains emit signal, itself slots function is more complex, etc.), it will cause confusion between the threads, it is possible that the contents of this slots function has not been executed, then went to execute after the content. So it can also produce unexpected results. You need to be aware of it in use.

Signal and slot functions, although to some extent, facilitate the invocation of functions before different modules, but too much use can cause problems such as being overly coupled between classes, causing confusion between signal and slot function calls to each other. So still have to depend on the specific circumstances of the specific analysis, reasonable right to use is the best.

Tips for using signals and slots in QT

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: 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.