[Interest] Gracefully Closing a QProcess

Jason R. Kretzer jason at gocodigo.com
Fri Aug 8 20:55:41 CEST 2014

Good Day!

I saw a partial question and answer to this a bit ago on this list but I 
have a follow up scenario.

I would like to start a QProcess and connect a SLOT to its 

In the SLOT, I would like to gracefully restart the process without 
triggering the error signal.

I have tried several ways but must be missing something.  Here is some 
sample code that I have been tinkering with:

///////////START CODE/////////////
//in an method in the "this" object
QProcess *proc = new QProcess();
QStringList arguments;
arguments << "str1" << "str2" << "str3";

connect(proc, SIGNAL(error(QProcess::ProcessError)), this, 
connect(proc, SIGNAL(finished(int)), proc, SLOT(deleteLater()));

//in the same file
void MainWindow::restartProcess(QProcess::ProcessError err)
     QProcess *proc = static_cast<QProcess*>(sender());

     qDebug() << "KILLING";
//I have used proc->kill() and proc->terminate() here as well

     qDebug() << "RESTARTING";
/////////END CODE

So, what happens is that the proc triggers an error when I 
kill/terminate/close it.  Which triggers the function, which kills the 
process, which triggers the error  etc etc.

In the end, not sure what is the "right" way to go about this. All I 
want to do is terminate and restart a process that has triggered an error.


Jason R. Kretzer
Lead Application Developer
jason at gocodigo.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140808/94e23ba1/attachment.html>

More information about the Interest mailing list