Get OS name

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

If single required

  1. ifdef Q_OS_LINUX

return QString::fromLatin1(DATADIR"/"APPLICATION_EXECUTABLE"/i18n/");

  1. endif
  2. ifdef Q_OS_MAC

return QApplication::applicationDirPath()+QLatin1String("/../Resources/Translations"); // path defaults to app dir.

  1. endif
  2. ifdef Q_OS_WIN

return QApplication::applicationDirPath();