3.7. Summary

KDE is based on Qt. Much of the code in KDE programs are Qt specific (using Qt widgets or features such as signals and slots), so you have to know Qt to be able to create KDE programs. It is highly recommended that you download the Qt reference from the official Trolltech Web site (http://www.trolltech.com).

The base class in Qt is QObject. If your class has signals or slots, your class must inherit from QObject.

QWidget is the base class for all visible classes.

Always use KDE widgets instead of Qt widgets when it's possible. That ensures that the look and feel of your KDE program is consistent with other KDE programs. Some features in KDE may also be better used by the KDE widgets.

You use signals and slots when you need to handle events. They are object independent. Each slot can respond to several signals. Several slots can respond to the same signal.

A widget that uses signals or slots does not have to be compiled with moc. The moc tool is only required when your class definition contains moc keywords. The moc keyword Q_OBJECT enables signals and slots.

Events handling is not the only use of signals and slots. Classes can use signals and slots for easy communication with each other. One example of this is when you have a program with several windows. It is common that the code for one window needs to execute some code for another window. This problem can be easily solved with signals and slots.

When you write MDI programs, the QList class may be used to store the window pointers.