The concept of signals and slots in QT

The signal is what event occurs, and the slot is what function is triggered, so the signal and slot are what event occurs (such as clicking a button) and then a certain function is triggered.

connect (the sender of the signal, the specific signal sent, the receiver of the signal, the processing of the signal)

connect(myButton , &QpushButton::clicked , this , &myWidget::close )

The first parameter is the button pointer

The second parameter is the signal sent. The types of signals are: (1) clicked, pressed and then released (2) pressed (3) released (4) toggled (click to switch a state)

The third parameter is the receiver of the signal

The fourth is the processing slot function (1) close() to close the window (2)

Now you click this button and it will close the window

 

 Custom signals and slots functions

The teacher object calls the hungry method, and the student object calls the treat method to treat the teacher to a meal.

 In fact, in the mitk source code, signals and slots are used like this:

 

 

Guess you like

Origin blog.csdn.net/weixin_47414034/article/details/131162068