[Qt-interest] QProcess flush issue
Joerg Bornemann
joerg.bornemann at nokia.com
Mon Oct 31 13:07:57 CET 2011
On 31/10/2011 11:41, ext Etienne Sandré-Chardonnal wrote:
> I have a console application binary which makes computations lasting
> roughly one hour. I am writing a Windows GUI that launches it with a
> QProcess. My GUI takes progress info from the standard output of the
> process and updates progress bars, etc...
> But the QProcess updates its standard output buffer only every few
> minutes and about 50 lines of output, which makes the progress bar not
> updating enough. When I launch the console application in a standard
> windows console, the output is updated at every line.
> So the question is : why is the QProcess not able to read more
> frequently from the standard output, where "cmd.exe" can? Is there
> anything configurable somewhere to improve the buffer refresh frequency?
cmd.exe is directly displaying the console buffer whereas QProcess is
reading stdout and stderr. These are different things.
QProcess is starting a child process and redirects its stdout to an
anonymous pipe with a buffer of 2048 bytes (AFAIR - I didn't look into
the code right now).
I think the effect you're seeing is a result of this buffering.
You can play around with the buffer size. But there's no Qt API to set
it - you will have to edit it in qprocess_win.cpp and recompile Qt for this.
BR,
Jörg
More information about the Qt-interest-old
mailing list