[<< Contents] [Next >>]
After starting KDevelop, from the Project menu select "New Project..." and open the tree structure to select "Basic Qt4 Application" in "C++/QMake project" (you may need to ensure "Show all project templates" is selected). Enter the application name and where you want the project located before pressing "Next".
Then enter your name and email address. You will also need to enter the location of the Qt4 qmake and designer applications on your machine. On my machine these are in "/usr/local/Trolltech/Qt-4.4.0/bin/" but they could well be in a different location on your machine. Press "Next", "Next", "Next", and "Finish".
KDevelop has now been setup to allow us to develop our Qt application and has automatically created some template code to get us started.
#include <QCoreApplication>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
qDebug("Hello from Qt 4!");
return 0;
}
|
If at any point KDevelop pops up any dialog boxes saying a file has changed, simply press "Reload". You can also close the "ReadMe" tab as we won't be needing this.
To compile this template code select the KDevelop "Build Project" option, either from the Build menu, the KDevelop toolbar, or keyboard shortcut (F8). As this is the first time we have tried to compile the code, KDevelop asks about running qmake as there is no Makefile. Select "Run qmake".
The template code should now be successfully compiled and ready to run by selecting the KDevelop "Execute Main Program" option, either from the Build menu, the KDevelop toolbar, or keyboard shortcut (Shift+F9). The template code writes the string "Hello from Qt 4!" to stderr which appears in the Application box at the bottom of KDevelop.
Hello from Qt 4!
Feel free to edit the "Hello from Qt 4!" string in main.cpp, re-compile and re-run to get familiar with the KDevelop interface. Notice that now there is a Makefile, KDevelop automatically re-compiles the code when necessary when we try to re-run the application after making a change.
[<< Contents] [Next >>]