So far I know several ways to
As a rule, the more header files there are, the longer it takes the compiler to parse each module. (Obviously precompiled headers render some of this moot.) So you generally want to include the fewest header files necessary to build your app correctly.
If you are only using a few classes in a given compilation unit, then just include the classes by name, in the modern style:
#include <QEvent> #include <QPainter> #include <QFont>
If you use a large number of classes from a given module, it is probably just as easy to include the module-level header, such as:
You generally only use the older
.h style if a newer style header doesn't exist.
Now precompiled headers mitigate many of these issues by compiling once into a binary form. But there is still a cost to loading the precompiled symbols into memory and searching through them at compilation time. So the less you put in, the more efficient the build will be.