I have a slot that is called passing some arguments used in a QProcess. I execute a external program with some of this arguments. The problem is that I want to have a queue for these processes, waiting until the previous process is finished to launch the next.
What do you think is the best/easiest way?
Here my method/slot:
void FirstCase::CallApp(QString text, QString pathAndFileName)
{
QString command = QString("App1.exe %1 -Z %2").arg(pathAndFileName).arg(message);
QProcess* process = new QProcess(this);
process->start(command);
}
EDIT Here the solution, if you need it:
Following the QStringList idea, my CallApp method just adds the command to the QStringList like:
list << command;
And then calls to Execute();
void FirstCase::Execute()
{
if(!list_.isEmpty()&&!executing_)
{
QProcess* p = new QProcess(this);
QString c = list_.takeFirst();
p->start(c);
executing_=TRUE;
connect(p, SIGNAL(finished(int)),this,SLOT(ExecFinished()));
}
}
void FirstCase::ExecFinished()
{
executing__=FALSE;
Execute();
}