Question

I am trying to wrap a colleges c++ code in a Qt widget.

However, his programs std output necessarily needs to be viewed. As of now I am assuming I will build a GUI and open a QProccess that will run his program (then send commands over that pipe).

So my question is there anyway to read the standard output of that program and display it in a qlabel or something similar (i.e. what functions should I be looking into)?

Was it helpful?

Solution

As the process runs, the QProcess object will emit the readyReadStandardOutput() signal as soon as there are data available on the standard output. You can subscribe to the signal, call readAllStandardOutput() from the connected slot and append (not replace) the data to your widget. If you don't need the data to be displayed as soon as it arrives, you can just wait until the process finishes and then read all the output as once.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top