且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Qt和Linux管道

更新时间:2022-12-01 07:49:28

您可以使用 QProcess .

#include <QDebug>
#include <QProcess>
#include <QString>

int main()
{
    QProcess echo;

    // call your program (e.g. echo) and add your input as argument
    echo.start("echo", QStringList() << "foo bar");

    // wait until your program has finished 
    if (!echo.waitForFinished())
        return 1;

    // read the output
    qDebug() << echo.readAll();

    return 0;
}