如何在PySide中获取由QProcess运行的命令的输出?

pol*_*eer 5 python qt qprocess pyside python-3.x

我想知道如何捕获PySide中QProcess运行的命令的输出,以便可以显示它.

pol*_*eer 3

我最终使用了这个:

  # 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.")
Run Code Online (Sandbox Code Playgroud)

然后在课堂上:

def newErrInfo(self):
  newString = str(self.runner.readAllStandardError())
  print(newString, end=" ")
Run Code Online (Sandbox Code Playgroud)

readAllStandardOutput() 也适用于标准输出