Hi, I am using using the following code to successfully collect the stout of the program I run with QProcess.
Process->start(program, args);
Process->waitForFinished();
QTextStream rsyncStdoutStream
(rsyncProcess
->readAllStandardOutput
());
while (true)
{
QString line
= rsyncStdoutStream.
readLine();
if (line.isNull())
break;
else
newFiles.append(line);
}
QProcess *Process = new QProcess;
Process->start(program, args);
Process->waitForFinished();
QTextStream rsyncStdoutStream(rsyncProcess->readAllStandardOutput());
while (true)
{
QString line = rsyncStdoutStream.readLine();
if (line.isNull())
break;
else
newFiles.append(line);
}
To copy to clipboard, switch view to plain text mode
The problem is that with this code the output is actually collected once the program is finished, so I do not have "live" access to it, which is actually what I am looking for (I would need this for other purpose). Simply not using the waitForFinished() function makes my program to crash.
i thought that using the QProcess::readyReadStandardOutput signal could be a solution, but AFAIK this would need to call a SLOT and with this it is not possible to return any value, which is my need. So I am a bit stuck at this point..
Thanks,
Jan
Bookmarks