KDE class names begin with a capital K. The first letter of each word making up the class name is also capitalized. For example, you used KSimpleApp as your class name in the code in Listings 2.3–2.5. Note that Qt class names follow a similar convention, but they all start with a capital Q.
The names of methods begin with a lowercase letter, but the first letter of each successive word is capitalized. For example, the method setBackgroundColor(), used in the constructor for KSimpleApp, is named with this convention. It is a Qt method (a member of QWidget) and follows the convention, as do all Qt methods.
Class and method names usually consist of one or more whole words or common abbreviations (such as "App" for application in the name KSimpleApp). Whole word names are easier to remember and make for more readable code.
Conventions are also used for filenames. Header files containing class definitions are given the name of the class, except that all letters are kept lowercase. The extension .h is used. Source files containing class definitions also use an all-lowercase version of the class name and carry the extension .cpp.
Prototypical examples of the naming conventions are collected in Table 2.2.
Table 2.2. KDE Naming Conventions
|Class declaration file||kmygreatclass.h|
|Class description file||kmygreatclass.cpp|