qt 调用 linux 命令,读取输出信息
class Process : public QObject
{
Q_OBJECT
public:
Process()
{
connect(&m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(onReadData()));
m_process.setReadChannel(QProcess::StandardOutput);
m_process.start("cmd /c ping /t www.qt.io");
}
private slots:
void onReadData()
{
qDebug() << m_process.readAllStandardOutput();
}
private:
QProcess m_process;
};