How to wait for process to finish
Hi,
I have the next call to run a scrip that unzip a zip:
process.startDetached("/bin/sh", QStringList()<< "/home/sg/Docs/MyScript.sh" << Arg1);
Once its unzipped, I want to make things with those files. The problem is that it seems that when I look for the files it says that they doen't exist (But they are in the folder and are readable and all ok).
It seems that its because the process hasn't finished yet unzipping because if i put a sleep(3) it works perfect. So my question is: how can I know when has process finished? I can't use a sleep cause its a gui aplicattion working on background.
Thank you.
Re: How to wait for process to finish
Don't use startDetached() but a real QProcess instance and connect to its signals.
Cheers,
_
Re: How to wait for process to finish
QProcess process;
And then how do you run the script? process.???
To connect it I suppose you mean to do something like:
connect(this, SIGNAL(process.finished()), this, SLOT(HasFinished());
declaring in the .h
Code:
private slots: HasFinished();
Re: How to wait for process to finish
Quote:
Originally Posted by
roseicollis
QProcess process;
And then how do you run the script? process.???
I recommend looking at the Qt documentation for QProcess.
Quote:
Originally Posted by
roseicollis
To connect it I suppose you mean to do something like:
connect(this, SIGNAL(process.finished()), this, SLOT(HasFinished());
Yes, but with a sender that actually makes sense and a valid signal name.
Quote:
Originally Posted by
roseicollis
declaring in the .h
Code:
private slots: HasFinished();
[/quote]
Right, but with actually correct syntax.
Cheers,
_
Re: How to wait for process to finish
Ok thank you :)
Edited: Implemented with process.start() and working :)