Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QProcess Real-time acquisition of output



  • I want to call external programs through QProcess in QT and get the output in real time。
    The core code is as follows:
    ota = new QProcess(this);
    connect(ota, &QProcess::readyReadStandardOutput, this, &Process::result);
    ota->start("./Process.exe");
    slots:
    void Process::result()
    {
    qDebug() << "start";
    qDebug() << ota->readAllStandardOutput();
    }
    The content in Process is as follows:
    printf("aaa");

    printf("bbb\n");
    
    printf("ccc");
    
    fflush(stdout);
    

    My expected output is:
    start
    aaabbb
    start
    ccc
    But my actual output is:
    start
    "aaabbb\r\nccc"
    Why is that?
    How can I get the output of the process in real time?
    Thank you!


  • Qt Champions 2019

    @zhiyuan_song said in QProcess Real-time acquisition of output:

    How can I get the output of the process in real time?

    What do you mean by 'real-time'? The output is exactly what you print out.


Log in to reply