shackra
shackra

Reputation: 366

How to use QProcess in headless script?

I'm trying to run another application and get its output from Stdout with this script:

p = QtCore.QProcess()
p.start("./mainapp.exe", [])
out = p.readAllStandardOutput()

logging.info("Test 2, output: {}".format(out))

however, I get this error when running:

QProcess: Destroyed while process is still running.

Upvotes: 1

Views: 157

Answers (1)

ekhumoro
ekhumoro

Reputation: 120598

You need to wait for the process to finish before you allow the script to exit:

p.start("./mainapp.exe", [])
p.waitForFinished()
out = p.readAllStandardOutput()

Upvotes: 3

Related Questions