PySide で QProcess によって実行されたコマンドの出力をキャプチャして表示できるようにする方法を知りたいです。
2409 次
2 に答える
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.")
その後、クラスの後半で:
def newErrInfo(self):
newString = str(self.runner.readAllStandardError())
print(newString, end=" ")
readAllStandardOutput() は stdout でも機能します
于 2012-05-19T13:56:30.230 に答える
2
QProcess qp;
qp.start("Yourcode");
qp.waitForFinished();
qDebug() << "qp:" << qp.readAll();
ライブで読むには、 canReadLine( )、readyread()、waitforreadyread()、waitforbyteswritten ()などの関数を使用できます。
これらの関数をシグナルスロットメカニズムで使用して、データをライブでキャプチャします。
于 2012-05-18T17:57:52.307 に答える