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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With