技术专栏
Qt获取系统信息
Qt获取系统信息
在开发过程中经常会遇到需要知道系统信息的时候,比如:屏幕尺寸、系统版本、语言信息等,本篇文章简单的分享一下我对这些内容的封装
#ifndef STYSTEMINFO_H
#define STYSTEMINFO_H
#include <QRect>
#include <QDesktopWidget>
#include <QApplication>
#include <QScreen>
#include <QDebug>
typedef struct{
QRect screenRect;
QRect deskRect;
int screenCount;
}screenInfo;
class stystemInfo
{
public:
stystemInfo();
// static screenInfo GetScreenInfo();
//获取屏幕宽度
static int getScreenWidth();
//获取屏幕高度
static int getScreenHeight();
//获取系统版本
static QString osVersion();
//获取默认语言
static QString defaultLangID();
// static
};
#endif // STYSTEMINFO_H
#include "stysteminfo.h"
stystemInfo::stystemInfo()
{
}
int stystemInfo::getScreenWidth()
{
QScreen *screen=QGuiApplication::primaryScreen ();
QRect sRect = screen->availableGeometry() ;
return sRect.width();
}
int stystemInfo::getScreenHeight()
{
QScreen *screen=QGuiApplication::primaryScreen ();
QRect sRect = screen->availableGeometry() ;
return sRect.height();
}
QString stystemInfo::osVersion()
{
QString versionInfo;
versionInfo.append(QSysInfo::productType()).append(QSysInfo::productVersion());
qDebug() << versionInfo;
return versionInfo;
}
QString stystemInfo::defaultLangID()
{
QString language = QLocale::system().name();
// QString language = QString::fromLocal8Bit("ru_");
language = language.mid(0,language.indexOf(QChar('_')));
return language;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
<
声明:本文内容由易百纳平台入驻作者撰写,文章观点仅代表作者本人,不代表易百纳立场。如有内容侵权或者其他问题,请联系本站进行删除。
红包
25
5
评论
打赏
- 分享
- 举报
评论
0个
手气红包

相关专栏
-
浏览量:2287次2020-05-12 15:55:12
-
浏览量:10615次2020-11-24 23:10:14
-
浏览量:7346次2020-11-24 23:18:39
-
浏览量:2351次2020-08-19 18:28:51
-
浏览量:9224次2020-07-17 12:21:58
-
浏览量:1776次2018-08-28 12:39:00
-
浏览量:535次2023-09-06 11:02:23
-
浏览量:2149次2020-09-24 14:36:09
-
浏览量:1855次2019-11-09 09:30:24
-
浏览量:2654次2020-06-29 10:47:11
-
浏览量:2071次2020-02-24 10:20:48
-
浏览量:14071次2020-12-09 09:53:36
-
浏览量:4385次2021-07-22 14:48:32
-
浏览量:3913次2020-08-21 19:40:26
-
浏览量:2778次2019-12-05 16:39:49
-
浏览量:5356次2017-11-18 16:34:44
-
浏览量:3157次2019-12-12 17:34:31
-
浏览量:9350次2021-01-08 01:26:48
-
浏览量:3282次2020-07-30 18:54:07
置顶时间设置
结束时间
删除原因
-
广告/SPAM
-
恶意灌水
-
违规内容
-
文不对题
-
重复发帖
打赏作者

小王子🤴
您的支持将鼓励我继续创作!
打赏金额:
¥1

¥5

¥10

¥50

¥100

支付方式:

举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
审核成功
发布时间设置
发布时间:
请选择发布时间设置
是否关联周任务-专栏模块
审核失败
失败原因
请选择失败原因
备注
请输入备注