[QT] signal and slot

Source: Internet
Author: User

The signal and slot mechanism is the extension of QT to C ++. This function is available only for the subclass of qobject.

Classes that support signals and slots must be derived from qobject and defined using the q_object macro.

 

The signal and slot mean that the caller and the called are separated to achieve high cohesion and low coupling.

 

Signal definition:

In the class, it is represented by the signals identifier.

The signal declaration and function declaration formats are the same, but they do not need to be implemented.

Signal has no access permission. The default value is protected.

Definition of Slot functions:

In the class, slots is used to represent the slots.

It can set access permissions.

It can be implemented in the same way as normal functions.

It can be called like a common function.

Signal and slot connections

Signal and slot can be many to many.

It can also be transmitted, that is, the signal can be connected to the signal.

The signal parameters must be more or the same than the slot.

The signal parameters must be consistent with the slot parameter types.

Both the signal and the slot support heavy load.

Signal call

Emit mysignal (); call the signal function with the reserved words of emit.

 

[QT] signal and 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.