Get OS name: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
<code> QString Get::osName()<br /> {<br /> #if defined(Q_OS_ANDROID)<br /> return QLatin1String("android&quot;);<br /> #elif defined(Q_OS_BLACKBERRY)<br /> return QLatin1String("blackberry&quot;);<br /> #elif defined(Q_OS_IOS)<br /> return QLatin1String("ios&quot;);<br /> #elif defined(Q_OS_MAC)<br /> return QLatin1String("osx&quot;);<br /> #elif defined(Q_OS_WINCE)<br /> return QLatin1String("wince&quot;);<br /> #elif defined(Q_OS_WIN)<br /> return QLatin1String("windows&quot;);<br /> #elif defined(Q_OS_LINUX)<br /> return QLatin1String("linux&quot;);<br /> #elif defined(Q_OS_UNIX)<br /> return QLatin1String("unix&quot;);<br /> #else<br /> return QLatin1String("unknown&quot;);<br /> #endif<br /> }<br /></code> | |||
If single required | If single required | ||
<code><br />#ifdef Q_OS_LINUX<br />return QString::fromLatin1(DATADIR&quot;/&quot;APPLICATION_EXECUTABLE&quot;/i18n/&quot;);<br />#endif<br />#ifdef Q_OS_MAC<br />return QApplication::applicationDirPath()+QLatin1String("/../Resources/Translations&quot;); // path defaults to app dir.<br />#endif<br />#ifdef Q_OS_WIN<br />return QApplication::applicationDirPath(); |
Revision as of 10:34, 24 February 2015
QString Get::osName()<br /> {<br /> #if defined(Q_OS_ANDROID)<br /> return QLatin1String("android&quot;);<br /> #elif defined(Q_OS_BLACKBERRY)<br /> return QLatin1String("blackberry&quot;);<br /> #elif defined(Q_OS_IOS)<br /> return QLatin1String("ios&quot;);<br /> #elif defined(Q_OS_MAC)<br /> return QLatin1String("osx&quot;);<br /> #elif defined(Q_OS_WINCE)<br /> return QLatin1String("wince&quot;);<br /> #elif defined(Q_OS_WIN)<br /> return QLatin1String("windows&quot;);<br /> #elif defined(Q_OS_LINUX)<br /> return QLatin1String("linux&quot;);<br /> #elif defined(Q_OS_UNIX)<br /> return QLatin1String("unix&quot;);<br /> #else<br /> return QLatin1String("unknown&quot;);<br /> #endif<br /> }<br />
If single required
#ifdef Q_OS_LINUX
return QString::fromLatin1(DATADIR"/"APPLICATION_EXECUTABLE"/i18n/");
#endif
#ifdef Q_OS_MAC
return QApplication::applicationDirPath()+QLatin1String("/../Resources/Translations"); // path defaults to app dir.
#endif
#ifdef Q_OS_WIN
return QApplication::applicationDirPath();