3.1.  Style Guidelines, Naming Conventions

[ fromfile: style.xml id: style ]

C++ is a powerful language that supports many different programming styles. The coding style used in most Qt programs is not “pure” C++. Instead, it uses combination of macros and preprocessor trickery to achieve a higher-level dynamic language that more closely resembles Java or Python than C++. In fact, to take full advantage of Qt's power and simplicity, we tend to abandon the Standard Library entirely.

We find there are certain aspects to “Qt programming style” that are worth emulating, and they are summarized here. For a more complete guide, see [qtapistyle] and [kdestyle].

For data members, we use a common prefix:

For each attribute, we have naming conventions for their corresponding getters/setters.

A consistent naming convention greatly improves the readability and maintainability of a program.



[15] The latter is Java style, the former is Qt style. Both conventions are widely used. Try to be consistent in your code, even if you find this book is not.