brazso
11th February 2009, 11:12
I wish to start an external process inside my gui application (QT v4.4.2, Win), the application can be suspended until the termination of that process. So far I used successfully the following code snippet:
QProcess process;
process.start("something", args);
if (!process.waitForStarted()){
// some error msg dialog
return;
}
if (!process.waitForFinished(-1))
return;
Then I could read the the complete output/error channel of the terminated process. However I wish I could process the output channels line by line during the operation of the process, because I want to feed a progress bar. Therefore I replaced the waitForFinished block to something like that:
while (process.state()==QProcess::Running /* || process.waitForReadyRead(1) */){
// reading process output channels
}
My problem is that this while loop never ends, the process state always remains in Running state. How can I achieve my aim without asynchronous usage?
QProcess process;
process.start("something", args);
if (!process.waitForStarted()){
// some error msg dialog
return;
}
if (!process.waitForFinished(-1))
return;
Then I could read the the complete output/error channel of the terminated process. However I wish I could process the output channels line by line during the operation of the process, because I want to feed a progress bar. Therefore I replaced the waitForFinished block to something like that:
while (process.state()==QProcess::Running /* || process.waitForReadyRead(1) */){
// reading process output channels
}
My problem is that this while loop never ends, the process state always remains in Running state. How can I achieve my aim without asynchronous usage?