当前位置: 首页 > news >正文

【QML】Qt和QML获取操作系统类型

1. Qt获取系统类型

//方法
QSysInfo::productType()//举例:
if(QSysInfo::productType() == "windows")
{qDebug() << "windows system";
}

官方说明:

[static] QString QSysInfo::productType()
Returns the product name of the operating system this application is running in. If the application is running on some sort of emulation or virtualization layer (such as WINE on a Unix system), this function will inspect the emulation / virtualization layer.
Values returned by this function are stable and will not change over time, so applications can rely on the returned value as an identifier, except that new OS types may be added over time.
Linux and Android note: this function returns "android" for Linux systems running Android userspace, notably when using the Bionic library. For all other Linux systems, regardless of C library being used, it tries to determine the distribution name and returns that. If determining the distribution name failed, it returns "unknown".
macOS note: this function returns "osx" for all macOS systems, regardless of Apple naming convention. The returned string will be updated for Qt 6. Note that this function erroneously returned "macos" for macOS 10.12 in Qt versions 5.6.2, 5.7.1, and 5.8.0.
Darwin, iOS, tvOS, and watchOS note: this function returns "ios" for iOS systems, "tvos" for tvOS systems, "watchos" for watchOS systems, and "darwin" in case the system could not be determined.
FreeBSD note: this function returns "debian" for Debian/kFreeBSD and "unknown" otherwise.
Windows note: this function "winrt" for WinRT builds, and "windows" for normal desktop builds.
For other Unix-type systems, this function usually returns "unknown".
This function was introduced in Qt 5.4.
See also QFileSelector, kernelType(), kernelVersion(), productVersion(), and prettyProductName().

在这里插入图片描述

2. QML获取系统类型

//方法
Qt.platform.os//举例
if(Qt.platform.os === "windows"){console.log("windows system")}else if(Qt.platform.os === "linux"){console.log("linux system")}

官方说明:

platform : objectThe platform object provides info about the underlying platform.
Its properties are:platform.os
This read-only property contains the name of the operating system.
Possible values are:"android" - Android"ios" - iOS"tvos" - tvOS"linux" - Linux"osx" - macOS"qnx" - QNX (since Qt 5.9.3)"unix" - Other Unix-based OS"windows" - Windows"winrt" - WinRT / UWP"wasm" - WebAssembly
platform.pluginName
This is the name of the platform set on the QGuiApplication instance as returned by QGuiApplication::platformName()This property was introduced in Qt 5.1.

在这里插入图片描述

http://www.lryc.cn/news/223913.html

相关文章:

  • CSS 显示、定位、布局、浮动
  • Java 学习笔记
  • 项目实战:优化Servlet,把所有围绕Fruit操作的Servlet封装成一个Servlet
  • Go语言函数参数
  • 【遍历二叉树的非递归算法,二叉树的层次遍历】
  • 数模之线性规划
  • 【C++】AVL树的4中旋转调整
  • 【MATLAB源码-第69期】基于matlab的LDPC码,turbo码,卷积码误码率对比,码率均为1/3,BPSK调制。
  • Java获取时间戳、字符串和Date对象的相互转换、日期时间格式化、获取年月日
  • 用c语言实现矩阵转置
  • 蓝桥杯官网练习题(移动距离)
  • 不止于“初见成效”,阿斯利康要让数据流转,以 AI 带动决策智能
  • nav2 调节纯追踪算法
  • 安装RabbitMQ
  • Spring基础(1):两个概念
  • 国产化精密划片机已得到国内更多厂家青睐
  • Voice Control for ChatGPT简单高效的与ChatGPT进行交流学习。
  • flutter生态一统甜夏 @Android @ios @windowse @macos @linux @Web
  • 计算机基础知识49
  • el-table给某一行加背景色
  • 搭建 Makefile+OpenOCD+CMSIS-DAP+Vscode arm-none-eabi-gcc 工程模板
  • Unity场景ab包加载压缩(LZ4,LZMA)格式的测试
  • 私有化部署大模型:5个.Net开源项目
  • 安卓系统手机便签app使用哪一款?
  • SpringCloud-Gateway无法使用Feign服务(2021.X版本)
  • 基于SSM的建筑装修图纸管理平台
  • Apache Doris (五十二): Doris Join类型 - Broadcast Join
  • Docker从入门到上天系列第四篇:docker平台入门图解与平台架构图解
  • 安全防御——四、防火墙理论知识
  • 如何给PPT幻灯片解除密码保护以防止编辑