[Qt-interest] stdout of MSWin GUI application run from console

Graeme Gill graeme2 at argyllcms.com
Thu Apr 14 02:24:23 CEST 2011


Rainer Wiesenfarth wrote:
> And maybe this is the reason why Qt does not offer a solution here.
> There is no cross platform common behavior:

Sounds like a self fulfilling loop to me. MSWin invented
the artificial distinction between GUI and console app.,
so people are used to that behaviour, so now that's used as a
justification for keeping an unnecessary distinction between a
GUI and console app! (Sounds a bit like Stockholm syndrome!).

> - A _Windows_ user assumes that a _GUI_ application, if by any weird
> circumstances started from a console, detaches itself and runs "in
> background" and independent of the console. Thus a GUI application that
> tries to give Windows look-and-feel should not use a console on Windows.

MSWin GUI applications started from a console to not "detach themselves".
Their behaviour is no different to Linux etc. in this regard. The only
difference is that they _assume_ that there is no console, and
stub out stdio. (Oh, and expect to start from WinMain etc. - but Qt
erases this distinction, to provide cross platform uniformity.)

> And, for completeness: for _console_ applications, both users assume
> that the application does not use any GUI at all (probably does not even
> need a device context or associated X-Display).

Incorrect assumption. I expect that a console application on
MSWin and Linux, and OS X, etc. may create GUI windows or even
a full blown GUI application.

> Writing cross platform GUI applications that act "native" on all
> platforms means: Do not use stdin, stdout, and stderr. And that is, what
> Qt supports... ;-)

Nothing compels you to use stdio if you are writing a GUI application.
Nothing compels you to create windows if you are writing a console
application. You can make an application purely one or the other if
you choose, or a mixture of both. The freedom is yours as an application
writer.

By default MSWin does compel you to make a choice as to whether your
application can write to stdio or pops a console window every time
it starts. There is no technical or user expectation reason to have
to make this choice.

Graeme Gill.



More information about the Qt-interest-old mailing list