How to get STDOUT from a QProcess?

喜欢而已 提交于 2019-11-27 08:02:20
Kamil Klimek

Before starting your process call:

process.setProcessChannelMode(QProcess::MergedChannels);

It will cause printing everything (even STDERR output) to STDOUT output.

Michel L

Here is some clarification:

According to http://doc.qt.io/qt-5/qprocess.html#ProcessChannelMode-enum,

  • QProcess::MergedChannels: QProcess merges the output of the running process into the standard output channel (stdout). The standard error channel (stderr) will not receive any data.[...]

but

  • QProcess::ForwardedChannels: QProcess forwards the output of the running process onto the main process. Anything the child process writes to its standard output and standard error will be written to the standard output and standard error of the main process.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!