Qt-- signals and slots

 

 

 

  • Signals and slots: a communication mechanism between objects
  • Observer pattern: When an event occurs, for example, a button is clicked detected himself a bit, it will send a signal (signal). This issue is no purpose, similar to the broadcast. If this signal has the object of interest, it will use the connection (Connect) function, meaning that a function of their own (a groove (slot)) to process the signal
  • Many beginners will encounter inexplicable error, a plus Q_OBJECT on the error, in large part because there is no notice of this macro should be placed in a header file
  • When a button is clicked, clicked it will send a signal, meaning that a statement to the surrounding components are: I clicked it! Of course, many other components are too lazy to care for him. If you are interested in it, I told QObject that you help me staring point, as long as the button clicked send out a signal, you tell me - after thought and said, well, you do not tell me, go directly to the Executive my such and such a function now! In this way, a signal groove is formed. Specifically it, this example is an example of a QApplication said that if the clicked signal button issue, quit you go to perform my function. So, when we click on the button the time, a function is called the quit, quit the program. So, here, clicked () is a signal, but quit () is a slot, the image that is inserted into the slot to the signal to go inside

reference

https://yq.aliyun.com/articles/9204

https://blog.csdn.net/zong596568821xp/article/details/78917689

 

Guess you like

Origin www.cnblogs.com/cxc1357/p/11817172.html