Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何获得PySide中QProcess运行的命令的输出?_Python_Qt_Python 3.x_Pyside_Qprocess - Fatal编程技术网

Python 如何获得PySide中QProcess运行的命令的输出?

Python 如何获得PySide中QProcess运行的命令的输出?,python,qt,python-3.x,pyside,qprocess,Python,Qt,Python 3.x,Pyside,Qprocess,我想知道如何在PySide中捕获QProcess运行的命令的输出,以便可以显示该命令。QProcess qp; QProcess qp; qp.start("Yourcode"); qp.waitForFinished(); qDebug() << "qp:" << qp.readAll(); qp.启动(“您的代码”); qp.waitForFinished(); qDebug()我最终使用了以下方法: # Create runner self.run

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

QProcess qp;
 QProcess qp;
 qp.start("Yourcode");
 qp.waitForFinished();
 qDebug() << "qp:" << qp.readAll();
qp.启动(“您的代码”); qp.waitForFinished(); qDebug()我最终使用了以下方法:

  # 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.")
然后在课程的后面:

def newErrInfo(self):
  newString = str(self.runner.readAllStandardError())
  print(newString, end=" ")

readAllStandardOutput()也适用于stdout

No,而不是在命令运行完毕之后。我的意思是命令正在运行,谢谢。不过,我想我找到了另一个答案。