I would like to know how I can capture the output of a command run by QProcess in PySide so that it can be displayed.
Asked
Active
Viewed 2,687 times
2 Answers
3
I ended up using this:
# Create runner
self.runner = QProcess(self)
# Make sure newInfo gets all output
self.runner.readyReadStandardError.connect(self.newErrInfo)
# Run the command
self.runner.start(command)
# Once it's started set message to Converting
self.parentWidget().statusBar().showMessage("Converting.")
Then later in the class:
def newErrInfo(self):
newString = str(self.runner.readAllStandardError())
print(newString, end=" ")
readAllStandardOutput() also works for stdout

polandeer
- 396
- 4
- 16
2
QProcess qp;
qp.start("Yourcode");
qp.waitForFinished();
qDebug() << "qp:" << qp.readAll();
For Reading live you can use functions like canReadLine(),readyread(),waitforreadyread() and waitforbyteswritten().
Use these functions in signal-slot mechanism for capturing data live.

ScarCode
- 3,074
- 3
- 19
- 32
-
No, not after the command has finished running. I mean as the command is running. – polandeer May 18 '12 at 18:00
-
Thank you. I think I've found another answer, though. – polandeer May 18 '12 at 18:26