[Qt-interest] How to capture stdout and redirect it to the gui?
Bob Hood
bhood2 at comcast.net
Thu Jan 27 04:21:40 CET 2011
On 1/26/2011 8:03 PM, K. Frank wrote:
> Hello Bob!
> I haven't used QProcess before, so let me ask some simple
> questions.
>
> In my case, I don't have a separate process; instead, I call an
> in-process library (that writes to stdout, and that I would prefer
> not to modify). Is it possible for an already running Qt gui process
> to get a handle to itself and read its own stdout? How would I
> go about doing this? Or does your method only work when the
> "main" process creates a second child process?
Sorry, I didn't fully understand your situation.
If it's a library function running from within your main process space, I'd
guess that means that it's piggy backing off your application's stdout. You
should be able to redirect your own stdout/stderr to a file or other mechanism
(like a pipe) before calling the library and then read the output from there.
This doesn't necessarily involve Qt; you can manipulate your stdout/stderr
file descriptors using just the standard C functions.
More information about the Qt-interest-old
mailing list