PDA

View Full Version : [QProcess] - executing application problem



Tomasz
29th July 2010, 18:29
Hello!

I want my application to execute the other application, so I wrote code like this:



void MainWindow::runApp()
{
QProcess *proc;
proc = new QProcess( this );
proc->start("/app", QStringList() << "-qws");
}


It's slot triggered by button. Application runs, but when I close It parent application is closing too with:



QProcess: Destroyed while process is still running


What I'm doing wrong?

thanks in advance
best regards
Tomasz

Zlatomir
29th July 2010, 18:41
Most likely you need the startDetached (http://doc.qt.nokia.com/latest/qprocess.html#startDetached)

tbscope
29th July 2010, 18:45
Well, if you look in the documentation you see this for the destructor of QProcess:


Destructs the QProcess object, i.e., killing the process.

It's pretty obvious that when you delete the process, the application will exit too.
Note that this is not what you want to do, you want to close the application gracefully, in a controlled way, otherwise you might have data loss.

Tomasz
30th July 2010, 09:04
Most likely you need the startDetached (http://doc.qt.nokia.com/latest/qprocess.html#startDetached)

Thaks! startDetached works fine, but I needed to run child application without "-qws" parameter.

best regards
Tomasz