Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. How to I get cpu description and cpu name
Forum Updated to NodeBB v4.3 + New Features

How to I get cpu description and cpu name

Scheduled Pinned Locked Moved Solved Language Bindings
7 Posts 2 Posters 4.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nathan Miguel
    wrote on last edited by
    #1
    #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.

    1. The first one and use the WMIC api in qt, but how do I do this?

    2. How can I convert the system () command from char to string in qt? because even reading the documentation, none of the forms presented worked.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Both can be done using QProcess.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      N 2 Replies Last reply
      3
      • SGaistS SGaist

        Hi,

        Both can be done using QProcess.

        N Offline
        N Offline
        Nathan Miguel
        wrote on last edited by Nathan Miguel
        #3

        @SGaist

        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

        0_1557079193990_Captura de tela de 2019-05-05 14-50-39.png

        #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()
        {
        
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          N 1 Reply Last reply
          1
          • SGaistS SGaist

            Hi,

            Both can be done using QProcess.

            N Offline
            N Offline
            Nathan Miguel
            wrote on last edited by
            #5
            This post is deleted!
            1 Reply Last reply
            0
            • SGaistS SGaist

              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.

              N Offline
              N Offline
              Nathan Miguel
              wrote on last edited by
              #6

              @SGaist Look, I've researched here, but would you have any idea of a script to just get the name of the gpu and its linux corporation? Because I'm just meeting for windows

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Something like lspci -vnn | grep VGA ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved