Get OS name

From Qt Wiki
Revision as of 10:34, 24 February 2015 by Maintenance script (talk | contribs)
Jump to navigation Jump to search
 QString Get::osName()<br /> {<br /> #if defined(Q_OS_ANDROID)<br /> return QLatin1String(&quot;android&amp;quot;);<br /> #elif defined(Q_OS_BLACKBERRY)<br /> return QLatin1String(&quot;blackberry&amp;quot;);<br /> #elif defined(Q_OS_IOS)<br /> return QLatin1String(&quot;ios&amp;quot;);<br /> #elif defined(Q_OS_MAC)<br /> return QLatin1String(&quot;osx&amp;quot;);<br /> #elif defined(Q_OS_WINCE)<br /> return QLatin1String(&quot;wince&amp;quot;);<br /> #elif defined(Q_OS_WIN)<br /> return QLatin1String(&quot;windows&amp;quot;);<br /> #elif defined(Q_OS_LINUX)<br /> return QLatin1String(&quot;linux&amp;quot;);<br /> #elif defined(Q_OS_UNIX)<br /> return QLatin1String(&quot;unix&amp;quot;);<br /> #else<br /> return QLatin1String(&quot;unknown&amp;quot;);<br /> #endif<br /> }<br />

If single required


#ifdef Q_OS_LINUX
return QString::fromLatin1(DATADIR&quot;/&quot;APPLICATION_EXECUTABLE&quot;/i18n/&quot;);
#endif
#ifdef Q_OS_MAC
return QApplication::applicationDirPath()+QLatin1String("/../Resources/Translations&quot;); // path defaults to app dir.
#endif
#ifdef Q_OS_WIN
return QApplication::applicationDirPath();