I was planning using QProcess to execute a program(.exe) in my computer and process a file which already exists, then output a new file and continue the next step, the whole process takes about 3 to 5 seconds.
However, although the process screen that doing the process does show up and running, and I also wrote lines of code to detect if the process has done, then do the next step, but yet can't stop the project from doing the following steps without waiting.
In other words, my project will try to open a file that isn't exist because it is still in process in the previous code.
So I wrote a simple code to test:
QProcess *proc = new QProcess(this);
ui->textEdit->append(QString("%1").arg(proc->state()));
ui->textEdit->append(QString("%1").arg(proc->exitCode()));
ui->textEdit->append(QString("%1").arg(proc->waitForStarted()));
ui->textEdit->append(QString("%1").arg(proc->waitForFinished()));
proc->startDetached("cmd");
ui->textEdit->append(QString("%1").arg(proc->state()));
ui->textEdit->append(QString("%1").arg(proc->exitCode()));
ui->textEdit->append(QString("%1").arg(proc->waitForStarted()));
ui->textEdit->append(QString("%1").arg(proc->waitForFinished()));
and the result was all "zero".
0
0
0
0
0
0
0
0
but the cmd.exe console is right there,
am I misunderstood about QProcess's exitcode functions?