Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.
How to use Signals and Slot in Qt
Here is the simple code which will demonstrate the use of the signals and slot in Qt. In this code first button does not connected to any function and it does nothing when you click on it. Second button emits a signal whenever you click on it and it is connected with the function quit.
int main(int argc, char *argv)
QApplication app(argc, argv);
QWidget* win = new QWidget();
QVBoxLayout* layout = new QVBoxLayout(win);
QPushButton* but1 = new QPushButton("Hello James");
QPushButton* but2 = new QPushButton("Bye Bye");
QObject::connect(but2, SIGNAL(clicked()), &app, SLOT(quit()));