2015-03-31 98 views
2

我應該單獨的模塊和報頭包括與像如何使用QtWinExtras在跨平臺應用程序

/// .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 

或者我可以忽略那些條件語句條件語句?

回答

1

如果你想編譯你的項目爲多個平臺,你一定要以條件方式使用它們。這是因爲像winextras,x11extras,macextrasandroidextras等模塊只適用於特定的操作系統。例如在Linux上,當製作一個使用winextras的項目時,qmake會給你提供錯誤。

除非您只想爲特定平臺編譯它,否則不需要使其具有條件。所以這一切都取決於你和你的用例。