![]() | Generating the source (alternate) |
| Prev | Next |
Step 1 - Be sure you saved your form with the name sigcreatedlg.ui and close Qt Designer. If you open this file with your favorite editor you will see that it is not C++ code but XML code. A special command line tool called uic is included with Qt Designer. This command is used to convert the .ui file into .h and .cpp files. This is handled automatically by KDevelop.
uic -o sigcreatedlg.h sigcreatedlg.ui uic -o sigcreatedlg.cpp -i sigcreatedlg.h sigcreatedlg.ui
Step 2 - You now have to inherit the class that KDevelop generated for you (the SigCreate class) from that new Qt Designer dialog class. In KDevelop, view the sigcreate.h file by selecting it in the File Selector and add
#include "sigcreatedlg.h"at the top of the sigcreate.h file, with all the headers you need.
#include <kapplication.h>
#include <qwidget.h>
#include <qlineedit.h>
#include <qmultilineedit.h>
#include <qcombobox.h>
#include <sigcreatedlg.h>
/** SigCreate is the base class of the project */
class SigCreate : public SigCreateDlg
{
Replace public KMainWindow by public SigCreateDlg because SigCreate inherits from SigCreateDlg.
You should have the following lines in sigcreate.h :
class SigCreate : public SigCreateDlg {
Q_OBJECT
public:
/** constructor */
SigCreate(QWidget *parent=0, const char *name=0);
/** destructor */
~SigCreate();
};
The file sigcreate.cpp should look like this:
#include "sigcreate.h"
SigCreate::SigCreate(QWidget *parent, const char *name) : SigCreateDlg(parent, name)
{
}
SigCreate::~SigCreate()
{
}
Step 3 - You have to add manually the include files as well. In sigcreate.h, you add the three following headers, one for each of the class we used:
#include <qlineedit.h> #include <qcombobox.h> #include <qmultilineedit.h>Step 4 - Comment out a few lines in the main.cpp file:
/* if (app.isRestored())
{
RESTORE(SigCreate);
}
else*/
as the project was intended to be based on a KMainWindow which offers a lot of facilities.
You can then run the project to see if everything is fine. First Build->Run automake & friends, then Build-> Run configure then Build->Build Project and Build->Install (or Install as root user) and Build->Execute Program (or Shift+F9). Please note that depending on your configuration, you might want to do Build->Install as root user instead of Build->Install if your user has no write access in your KDEDIR. You also can skip the install step, it's OK for the tutorial but might lead to problems in real world). The interface should appear but the Create! button does not work for the moment. We do that now by implementing the slot slotCreateSig(). See picture 19 below.
If you get the following error when compiling: Syntax error before `{' token" referring to the opening brace right /before/ the Q_OBJECT line in sigcreate.h, then you forgot to add
#include "sigcreatedlg.h"or the sigcreatedlg.h file is not created (cf note above).

| Prev | Home | Next |
| Useful links | Up | Implementing the slot |