Das K Desktop Environment

2.2. What KDE provides

2.2.1. The KDE 1.1.x libraries

For the time of this writing and due to the fact that KDevelop uses KDE 1.1, I'm referring to the state of the KDE libraries at that release. The main KDE libraries you'll be using for creating your own KDE applications are:

Additionally, for specific solutions KDE offers the following libraries:

Next, we'll have a look at what is needed to turn our first Qt application into a KDE one.

2.2.2. Example KDE Application

In the following, you will see that writing a KDE application is not much more difficult than a Qt application. For the use of KDE's features, you just have to use some other classes, and you're almost done. As an example, we'll discuss the changed version of the Qt example from above:

 #include <kapp.h>
 #include <qpushbutton.h>
 
 int main( int argc, char **argv )
 {
 KApplication a( argc, argv );
 
 QPushButton hello( "Hello world!" );
 hello.resize( 100, 30 );
 
 a.setTopWidget( &&;hello );
 
 connect(&&;hello, SIGNAL( clicked() ), &&;a, SLOT( quit() ));
 
 hello.show();
 return a.exec();
 }

You see that first we have changed from QApplication to KApplication. Further, we had to change the previously used setMainWidget() method to setTopWidget, which KApplication uses to set the main widget. That's it ! Your first KDE application is ready- you only have to tell the compiler the KDE include path and the linker to link in the KDE-Core library with -lkdecore.

As you now know what at least the main() function provides generally and how an application gets visible and allows user and object interaction, we'll go on with the next chapter, where our first application is made with KDevelop- there you can also test everything which was mentioned before and see the effects.

What you should have looked into additionally until now is the reference documentation for Qt , especially the QApplication, QWidget and QObject class and the KDE-Core library documentation for the KApplication class. The KDE Library Reference handbook also covers a complete description about the invocation of the QApplication and KApplication constructors including command-line argument processing.