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;
};

参考: https://zhuanlan.zhihu.com/p/86206831

标签: Qt

添加新评论