[Solved] Launching an exe independent of parent aplication?
-
Hi,
I want to launch an exe from my application, but I do not want to have any connection between them i.e. the child exe should be independent of the parent exe so that closing the parent exe does not close the child exe. I believe QProcess is used to launch an exe in Qt. So here is my code://SessionManager subclasses QDialog
@void SessionManager::on_resume_clicked()
{
QList <QListWidgetItem *> items = ui->sessionList->selectedItems();
for(int i = 0; i < items.size(); i++)
{
QStringList args;
args.append("-Session");
args.append(items.at(i)->text());
QString path = QApplication::arguments().at(0);
QProcess *proc = new QProcess();//memory leak!!!!!!!
proc->start(path, args);
}
close();
}@As can be observed this fulfills my requirement but causes a memory leak. Now if I add this as the parent of proc in its contstructor then when I close my parent exe all child exe's get closed. I don't want this.
Alternatively if I create proc in stack instead of heap then the child exe is not launched at all. It throws a warning that QProcess terminated before it was finished.
Any guidance would be very helpful to me in this matter... -
See startDetached:
http://qt-project.org/doc/qt-5/qprocess.html#startDetached -
Thanks for your help :)