Qt: is there a way to send a signal when a QProcess writes a line to stdout

前端 未结 3 823
独厮守ぢ
独厮守ぢ 2021-01-13 17:39

I\'ve found similar questions but never the exact answer. I have Qt program that starts a QProcess and writes the output to a QTextEdit box, so far so good. But it only does

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-13 18:37

    I use readAllStandardOutput() for this exact purpose and it works for me.

    However I did note that it won't recieve any standard output until the process actually flushes its output buffer ("\n" may not automagically do this, at least not in my entirely platform specific Windows experience).

    Depending on how the child process writes its output (either a C app or a C++ app), it needs to call fflush(stdout); or end lines with std::endl; respectively.

提交回复
热议问题