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
}

本文标签: 操作系统QT