I am try to wait child process with this code:
auto child = new QProcess;
child->start("cmd.exe");
child->waitForFinished();
But cmd.exe doesn't open and the main program runs. What is the error?
And how I should wait correctly? waitForFinished
waits 30000 msecs by default. What if I want to wait infinitely?
I suggest checking the return value to see if the program is started successfully using the waitForStarted
( doc ) and try to use the full path of CMD: "C:/windows/system32/cmd.exe"
.
Also, check online, the question is already been asked here .
To wait infinitely you need to call waitForFinished
with -1 ( doc ):
child->waitForFinished(-1);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.