![]() | Implementing the slot |
| Prev | Generating the source (alternate) | Next |
For the program to work, we want to click on the Create! button and that should display the signature in the TextEdit field. It is worth to look at the Qt documentation for each widget to see what are the already available signals and slots. For example, have a look at the QPushButton class documentation. It inherits from QButton and in the QButton doc you can easily see the signals that are already available.
Signals void pressed () void released () void clicked () void toggled ( bool on ) void stateChanged ( int state )So the signal we need here is clicked(), emitted from the Create! pushbutton.
As SigCreate is a class that is derived from SigCreateDlg, we implement our slot in the SigCreate class. It will be a public method. In sigcreate.cpp, we add these lines:
void SigCreate::slotCreateSig()
{
sigBox->append("\n--");
sigBox->append(nameBox->text());
sigBox->append(mailBox->text());
sigBox->append(commBox->currentText());
}
and of course we declare that method in the sigcreate.h file as following:
public slots:F
virtual void slotCreateSig();
In the above code, you see that in sigBox which is the TextEdit there will be "--" then the text from the nameBox (the name you entered) then the email address plus the comment. append() is a QTextEdit method and there are a lot of member functions for such a widget so you just have to read the class documentation to find which method you need and to get to know what the widget capabilities are.
Build the project again (Build->Build Project then Build->Install or Build->Install as root user) and run the program. Here is what you should get:

| Prev | Home | Next |
| Generating the source (alternate) | Up | Credits and License |