Das KDevelop-Programmierhandbuch: Leitfaden zur C++-Anwendungsentwicklung für das K Desktop Environment (KDE) mit Hilfe der KDevelop-IDE in der Version 1.2
Zurück | Kapitel 2. The KDE and Qt Libraries | Vor

# 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:

- the KDE-Core library, containing all classes that are non-visible elements and provide functionality your application may use.

- the KDE-UI library, containing user interface elements like menu bars, toolbar s and the like,

- the KFile library, containing the file selection dialogs,

Additionally, for specific solutions KDE offers the following libraries:

- the KHTMLW library, offering a complete HTML-interpreting widget that is used by various programs like KDEHelp , KFM, KDevelop,

- the KFM library, allowing to use the KDE file manager from within your application.

- the KAb library, the KAddressBook. Provides address-book access for e.g. email applications

- the KSpell library, offering widgets and functionality to integrate the use of Ispell, the common spell-checker, in applications like editors; used for the KEdit application.

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.

Zurück | Anfang | Vor
The KDE and Qt Libraries | Hoch | Creating new Applications