admin管理员组文章数量:1023119
在Qt中可以使用宏定义很方便的判断当前的操作系统类型;
判断是否为Windows
bool SystemInfo::isWindows()
{
#ifdef Q_OS_WINDOWS
return true;
#else
return false;
#endif
}
判断是否为win10
在调用QSysInfo::productVersion().startsWith(“10”)接口前,记得先调用isWindows()接口;
bool SystemInfo::isWindows10()
{
if (isWindows())
{
return QSysInfo::productVersion().startsWith("10");
}
return false;
}
判断是否为Mac
bool SystemInfo::isMacOS()
{
#ifdef Q_OS_MACOS
return true;
#else
return false;
#endif
}
在Qt中可以使用宏定义很方便的判断当前的操作系统类型;
判断是否为Windows
bool SystemInfo::isWindows()
{
#ifdef Q_OS_WINDOWS
return true;
#else
return false;
#endif
}
判断是否为win10
在调用QSysInfo::productVersion().startsWith(“10”)接口前,记得先调用isWindows()接口;
bool SystemInfo::isWindows10()
{
if (isWindows())
{
return QSysInfo::productVersion().startsWith("10");
}
return false;
}
判断是否为Mac
bool SystemInfo::isMacOS()
{
#ifdef Q_OS_MACOS
return true;
#else
return false;
#endif
}
版权声明:本文标题:Tip2 Qt中判断当前的操作系统 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/jiaocheng/1743912357a2051318.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论