PDA

View Full Version : Free memory with QProcess



Luc4
8th March 2010, 11:17
Hi! I run a process using the start method of QProcess:


QProcess* proc = new QProcess();
proc->start(path);

but, is there a way to free the memory after the process has returned? If I delete proc after starting, obviously I get that no process is run... Is there any other way?
Thanks!

^NyAw^
8th March 2010, 11:19
Hi,

Just connect QProcess::finished signal to your slot, so when the process finish your slot will be executed.

wysota
8th March 2010, 11:21
If you want to release the QProcess object after it is no longer required then do it... after it is no longer required, i.e. after it signals finished().


connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)), proc, SLOT(deleteLater()));
Another way is to pass a parent object to QProcess - it will then be deleted when the parent is deleted.

Luc4
8th March 2010, 11:55
This is great! Thank you very much!