How to I get cpu description and cpu name
-
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QDesktopServices> #include <QSysInfo> #include <QUrl> #include <QString> #include <iostream> #include <cstdlib> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); //set OS base info QString OSName = QSysInfo::productType(); ui->osName->setText(QSysInfo::productType().toUpper()); ui->cpuArch->setText(QSysInfo::currentCpuArchitecture().toUpper()); if (OSName == "windows") { QChar getcpu = system("wmic cpu get description"); QString cpucorp = "convert getcpu to string"; ui->cpuCorp->setText("view the cpucorp output"); } } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_actionSettings_triggered() { ui->stackedWidget->setCurrentIndex(1); } void MainWindow::on_ReturnBtn_clicked() { ui->stackedWidget->setCurrentIndex(0); } void MainWindow::on_actionGithub_triggered() { QString gitlink = "https://github.com/nathanmiguel123/Denoiser-Script"; QDesktopServices::openUrl(gitlink); }
![0_1556732995413_ee0dff76-a0af-46bf-a1a4-2471d80c52ae-image.png](Uploading 100%)
I need the program to get the name of the cpu and its "Intel / Amd" corporation, but I saw two ways to do that.
-
The first one and use the WMIC api in qt, but how do I do this?
-
How can I convert the system () command from char to string in qt? because even reading the documentation, none of the forms presented worked.
-
-
Sorry for "delay", in windows until it occurred + - as I wanted, but in Linux it does not display the information I want from the right way
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QDesktopServices> #include <QSysInfo> #include <QUrl> #include <QProcess> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); //set OS base info QString OSName = QSysInfo::kernelType(); ui->osName->setText(QSysInfo::kernelType().toUpper()); ui->cpuArch->setText(QSysInfo::currentCpuArchitecture().toUpper()); if (OSName == "winnt") { ui->selectHardware->addItem("CPU"); ui->selectHardware->addItem("GPU"); //get cpu name QString cpucorp = "wmic cpu get name"; QProcess windowscpu; windowscpu.start(cpucorp); windowscpu.waitForFinished(); QString windowsOutput = windowscpu.readAllStandardOutput().toUpper(); ui->cpuCorp->setText(windowsOutput); //get gpu name QString gpuname = "wmic PATH Win32_videocontroller get VideoProcessor"; QProcess windowsGpu; windowsGpu.start(gpuname); windowsGpu.waitForFinished(); QString windowsgpuoutput = windowsGpu.readAllStandardOutput(); ui->gpuName->setText(windowsgpuoutput); //get gpu vendor QString gpuvendor = "wmic PATH Win32_videocontroller get AdapterCompatibility"; QProcess windowsGpuvendor; windowsGpu.start(gpuvendor); windowsGpu.waitForFinished(); QString windowsgpuVendoroutput = windowsGpu.readAllStandardOutput(); ui->gpuVendor->setText(windowsgpuVendoroutput); //hability optiX QString nvidia = "NVIDIA"; bool isNvidia = windowsgpuVendoroutput.contains("NVIDIA"); if (isNvidia == true){ ui->selectHardware->addItem("OptiX"); } else { } } else if (OSName == "linux") { QProcess linuxcpuinfo; QString linuxcpu = "cat /proc/cpuinfo | grep 'model name' | uniq"; linuxcpuinfo.start(linuxcpu); linuxcpuinfo.waitForFinished(); QString linuxOutput = linuxcpuinfo.readAllStandardOutput(); ui->cpuCorp->setText(linuxOutput); } //disable denoiserbox if (ui->selectHardware->currentText() == "OptiX"){ ui->denoiserBox->setEnabled(false); } } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_actionSettings_triggered() { ui->stackedWidget->setCurrentIndex(1); } void MainWindow::on_ReturnBtn_clicked() { ui->stackedWidget->setCurrentIndex(0); } void MainWindow::on_actionGithub_triggered() { QString gitlink = "https://github.com/nathanmiguel123/Denoiser-Script"; QDesktopServices::openUrl(gitlink); } void MainWindow::on_toolButton_clicked() {
-
That's because you are using pipes in your command. Either user several QProcess objects from which you connect the standard output to the following process standard input or write a script that does that.
Note that since it's a file, you can also use QFile to read from it.
-
This post is deleted!
-
Something like
lspci -vnn | grep VGA
?