[Qt-interest] How to capture stdout and redirect it to the gui?

Gabriel M. Beddingfield gabrbedd at gmail.com
Thu Jan 27 04:42:37 CET 2011


On Wednesday, January 26, 2011 09:03:28 pm K. Frank wrote:
> 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?

freopen() will let you redirect your own stdout.  See 
http://www.cplusplus.com/reference/clibrary/cstdio/freopen/

-gabriel



More information about the Qt-interest-old mailing list