728x90

QProcess를 이용해서 cmd 명령어를 실행 후 결과를 얻어오는 코드입니다.

QProcess *m_process = new QProcess(this);

QString program = "ipconfig";
QStringList arguments;

arguments << "/all";

m_process->start(program, arguments);
m_process->waitForFinished(3000);

QByteArray result = m_process->readAll();
auto converter = QStringDecoder(QStringDecoder::System);
QString string = converter(result);
qDebug() << string;

m_process->close();
delete m_process;
728x90

+ Recent posts