|
需求
使用Qt软件开发一个检测cpu温度的功能。 兼容windows、linux,国产麒麟系统(同为linux)
Demo
功能描述 v1.1.0
- windows上定时检测输出cpu温度。
- linux上定时检测输出cpu温度。
- 国产银河麒麟操作系统上输出cpu温度。
模块化部署
关键源码
#ifndef LINUX
QString cmd = QString("wmic /namespace:\\\\root\\wmi PATH MSAcpi_ThermalZoneTemperature get CurrentTemperature");
QProcess process;
process.start(cmd);
process.waitForFinished();
QString result = process.readAllStandardOutput();
LOG << result;
result = result.replace("\r", "");
LOG << result;
QStringList list = result.split("\n", QString::SkipEmptyParts);
LOG << list;
bool ok = false;
int t = 0;
for(int index = 0; index < list.size(); index++)
{
QString str = list.at(index);
str = str.trimmed();
LOG << str;
t = str.toInt(&ok);
if(ok)
{
break;
}
}
|