[Development] Stopping a QProcess gracefully
achartier at fastmail.fm
achartier at fastmail.fm
Thu Aug 7 08:19:49 CEST 2014
Hello,
I am trying to find the proper way to gracefully exit a QProcess. The
particular process that I am running does some work and then is in a
waiting state, exiting only when the user presses the Enter key. This
works fine when the executable is run from the command line.
The problem I am having is that every way I have tried to stop the
QProcess results in the error signal being emitted; in such cases,
errorString() always returns "Process crashed". I have tried:
(1) Calling QProcess::terminate()
(2) Calling QProcess::kill()
(3) Writing the return key to the process with QProcess::write("\r") and
QProcess::write("\\r)
(4) Sending a Qt::Key_Return using qApp->sendEvent() to the QProcess
object (though it's not clear to me that QKeyEvents sent to the QProcess
get automatically forwarded to the executable they have spawned).
In summary, how can I stop this QProcess properly without having the
error signal emitted?
Thanks!
More information about the Development
mailing list