Creating a signal to slot connection in Qt Designer
Signal and slot is a mechanism used in Qt program by which the signal initiate one action and according to that action slot is affected or change its state.For the beginner of the Qt programmer this is difficult to understand the signal and slot style.
I have created the GUI application using signal and slot example. The steps are given below.
The below are steps for understanding signal and slot in GUI application in the Qt.
First of all open the Qt Creator window and start a new file or new project. In new project you need to new create the GUI application.
In GUI application blank .ui file is created where you can drop some widget from Qt designer window.
For more details about Qt Designer go to this link:Qt Designer
I have used one spin box and LCD number for better understanding of signal and slot.
You have to drag and drop the spin box and LCD number from Qt Designer list. After drag and drop final figure is given below.
Now in this example spinbox is signal and LCD number is my slot, For making this I have to press F4 or click in the signal slot edit mode which is at the above of .ui file. See this in below figure.
After that your mouse is activated and you have to connect your signal means spinbox with slot means LCD number.When you put cursor in the spinbox it will covered by red line. After that you have to click on it and connect it with LCD number means slot by arrow.The final figure is given below.
Now when you release the left key of your mouse you will get one window of configure connection which is given below. In which you have to connect signal action with slot reaction. In my example I have connected action as valueChanged(int) with reaction as display(int). See the below figure for this action.
Now final .ui file is available with blue boundary of spinbox and LCD nnumber,Also you can change the signal slot action using signal and slot editer which is given below in .ui file. The final figure is given below.
Now you can save all your work and then run your project. You will get the below output. When you increase the value of spinbox the value of LCD number also increases and vice versa is true. See the below figure.
Code (zip file) of this example is available at: File:Signalslotexample.zip