KDE programming tutorial using KDevelop

KDE programming tutorial using KDevelop

A programming tutorial by Richard Crook



The aim of this tutorial is to give programmers new to KDE application development a helping hand by showing how to develop an example full KDE application step by step. I will try to explain most lines of code and to give background information on how some of the design decisions are made.

As with most tutorials of this type, the pre-requisites are some knowledge of C++ and access to a system running KDE with KDevelop installed.

The development environment I used for developing this tutorial was Mandrake 10, which provides KDE 3.2 and KDevelop 3.0. If you also choose to use Mandrake 10 then you will need to ensure that you have the latest versions of automake (1.7) and autoconf (2.59) installed as these are not installed by default even when selecting the "Development" package group during the main installation. I would also recommend avoiding Mandrake 10.1 as this currently appears to have problems with KDevelop.

Please, if you do have any suggestions for improvements or spot any mistakes, please email me.

The example application is to simulate packet radio networks with a graphical user interface, but please don't be concerned by this as it is the KDE programming techniques that are important in this tutorial rather than the application itself.


Part 1: Getting started
In this part we will start the project in KDevelop and compile and run our first KDE application!

Part 2: First changes
Here we will start to modify the template code generated by KDevelop to start developing our example application.

Part 3: Adding a menu bar and a status bar
Here we start to construct the main menubar and add a statusbar.

Part 4: Adding a canvas
Now we add a canvas for us to later display our application specific graphics.

Part 5: Enhancing the canvas
Set a minimum size for the canvas and display more details on our status bar.

Part 6: Drawing on the canvas
Placing symbols on the canvas to represent the radio stations in our simulation.

Part 7: Adding a tool bar
Adding a toolbar with some edit mode icons and the associated menu options.

Part 8: Moving and deleting canvas items
Here we implement the canvas functionality for the new edit modes.

Part 9: Saving to a file
Saving our application data to an XML file.

Part 10: Loading from a file
And the ability to load from our XML files.

Part 11: New and Quit
Here we will add two more file menu options.

Review of what we have done.

Hope you have found this tutorial useful. Please check back in the future as I plan to extend it when I get the time.

Other suggest readings

The Trolltech Qt whitepaper gives an excellent introduction to capabilties and scope of the Qt toolset. The Qt documentation is some of the best I have ever seen. Have a look at it and the KDE documentation whenever you wonder what a class does.

Useful links

KDE homepage
KDevelop homepage
Stroustrup C++
Independent Qt tutorial
Other KDE tutorials
Mandrake Linux (now Mandriva Linux)

Last updated 24-Nov-2007