Should i seperate module and header includes with conditionals like
/// .pro file
win32:QT += winextras
/// .cpp file
#ifdef Q_OS_WIN
#include <QtWin>
#endif
/// ... later
#ifdef Q_OS_WIN
QWinTaskbarButton *taskbarButton = new QWinTaskbarButton(this);
#endif
or can i omit those conditionals?
If you want to compile your project for multiple platforms, you should definitely use them in a conditional manner. That's because modules like winextras
, x11extras
, macextras
and androidextras
are only available for the specific OS. For example on Linux, qmake would give you errors when making a project that uses winextras
.
Unless you want to only compile it just for the specific platform then there is no need to make it conditional. So it all depends on you and your use case.