简体   繁体   中英

How to use QtWinExtras in cross-platform application

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM