There is too much information about this concept on the Internet, these materials are very sound, such as the following articles, after two high-end, and now not fully understand, thank tingsking18 great God
http://www.ibm.com/developerworks/cn/linux/guitoolkit/qt/signal-slot/
http://blog.csdn.net/tingsking18/article/details/4800828
http://blog.csdn.net/tingsking18/article/details/4991563
Next, let's talk about some of the considerations you have encountered, about the parameters of the connect signal and slot
1, the signal and the number of parameters in the slot and the type must be exactly the same , what meaning, look at the following code, once an error:
Connect (button, SIGNAL (clicked ()), this, SLOT (SendMessage (QString)));
The original intention is to connect the Qpushbutton clicked () Signal and Groove SendMessage (), wherein the slot has a formal parameter type of qstring, so that all compiled through, but debugging when found that the slot function is not in, the problem occurs in the signal and the slot function of the parameter number is not the same. Change the above code to connect (but, SIGNAL (clicked (QString)), this, SLOT (SendMessage (QString))); Note that this is a bug in QT that uses signal () and slot (), which does not check for errors at compile time, and only outputs errors in the program's output window at run time. I use the VS2010 to debug, observe the Output window, you will find the following error output:
qobject::connect:incompatible sender/receiver Arguments
Mybutton::clickbutton ()-Onefloor::sendmessage (QString)
In addition, the parameter type must be exactly the same, that is, the signal parameter is qstring, the slot parameter must also be qstring, not int corresponds to qstring. This is the meaning that the number of parameters in the signal and slot must be exactly the same as the type.
This problem is recommended in QT5 a more secure approach, discussed below
2, the signal and slot function can not be a tangible parameter name . Or do you see a wrong example?
Connect (button, SIGNAL (config (QString ABC)), this, SLOT (configaddr (QString str)));
Still the same, compile without error, the runtime can see the error in the Output window, the final result is of course the slot function is not responding.
The above mentioned QT5 will recommend a method of use, you can avoid the signal with the slot to run the Times wrong, inconvenient to find errors.
Connect (obj1, &classa::fun1, Obj2, &classb::fun2);
For the first example, it is written so Connect (button, &mybutton::clickbutton, this, &onefloor::sendmessage);
In this way, it is possible to check the presence of the signal and slot when compiling, and to check the parameter type.
For instructions on connect in QT5, refer to the following two blog posts http://blog.csdn.net/dbzhang800/article/details/6547196 and http://www.linuxidc.com/ Linux/2014-04/100581.htm
Signal and slot of QT