Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, April 2008
text output to console on MSWindows


Message 1 in thread

Hi,

If I compile a program like the following using
qmake +mingw32 on MSWindows,
I do not see any output on the console.
int main(int argc,char** argv ) { printf("hello world\n"); return 0;}

I already figured out, that this is not the case if my pro-file 
includes: CONFIG += console

Question:
Does it has any side-affects if I add "CONFIG += console" to pro-files 
of GUI-apps, because I need console-textoutput on windows.

Qt-doc only says the following:
"The target is a Win32 console application" on 
http://doc.trolltech.com/4.3/qmake-variable-reference.html#config

Greetings
Jens

--
 [ signature omitted ] 

Message 2 in thread

On Friday 04 April 2008, Jens wrote:
> Question:
> Does it has any side-affects if I add "CONFIG += console" to pro-files
> of GUI-apps, because I need console-textoutput on windows.

Yes: even if you start the application from a menu or from the Windoze 
Explorer it will also open a console window and show your output in it. 
There is no possibility to get rid of the console window, since you kill 
the application if you kill the console.


	Konrad

Attachment:

Attachment: pgpNy5oLsVwPk.pgp
Description: PGP signature


Message 3 in thread

Konrad Rosenbaum wrote:
> On Friday 04 April 2008, Jens wrote:
>   
>> Question:
>> Does it has any side-affects if I add "CONFIG += console" to pro-files
>> of GUI-apps, because I need console-textoutput on windows.
>>     
>
> Yes: even if you start the application from a menu or from the Windoze 
> Explorer it will also open a console window and show your output in it. 
> There is no possibility to get rid of the console window, since you kill 
> the application if you kill the console.
>
>   
What I usually do is:
CONFIG(debug, debug|release):CONFIG *= console

This lets me see debug messages, but I still end up with a clean release 
build.

--
 [ signature omitted ] 

Message 4 in thread

On Friday 04 April 2008 14:18:55 Jens wrote:
>because I need console-textoutput on windows.
http://www.microsoft.com/technet/sysinternals/Miscellaneous/DebugView.mspx


-- 
 [ signature omitted ] 

Message 5 in thread

Hi,

thanks for your answers...

for debugging it is good to know, that I could use
	CONFIG(debug, debug|release):CONFIG *= console
to see debug-output.

But actually I want an update-tool to start my application with 
"--version" flag to make it return only the version (eg. 0.9.8) to my 
updater-tool.

The updater is written with Qt, too. So I use QProcess to start "myApp 
--version" and want to read this way the version-string:

	process.start("myApp.exe", QStringList("--version"));
	process.waitForFinished(10000);
	QString version = process.readAllStandardOutput();

It works fine on Unix... But on Windows I have no idea how to read the 
version of my app, because readAllStandardOutput() returns nothing if I 
do not use CONFIG+=console

Greetings
Jens

Jens schrieb:
> Hi,
> 
> If I compile a program like the following using
> qmake +mingw32 on MSWindows,
> I do not see any output on the console.
> int main(int argc,char** argv ) { printf("hello world\n"); return 0;}
> 
> I already figured out, that this is not the case if my pro-file 
> includes: CONFIG += console
> 
> Question:
> Does it has any side-affects if I add "CONFIG += console" to pro-files 
> of GUI-apps, because I need console-textoutput on windows.
> 
> Qt-doc only says the following:
> "The target is a Win32 console application" on 
> http://doc.trolltech.com/4.3/qmake-variable-reference.html#config
> 
> Greetings
> Jens
> 
> -- 
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
> 

--
 [ signature omitted ] 

Message 6 in thread

On Monday 07 April 2008 14:06:27 Jens wrote:>
> 	process.start("myApp.exe", QStringList("--version"));
> 	process.waitForFinished(10000);
> 	QString version = process.readAllStandardOutput();

- check the return of waitForFinished
- try waiting for started
- use stderr in your program instead

-- 
 [ signature omitted ] 

Message 7 in thread

On Tuesday 08 April 2008 18:58:43 you wrote:

> Perhaps I should report that to fix as a wish to trolltech.
not really a Qt bug. thats how windows pipes work afaik.
tried using stderr?
there is some flag that eneables stdout, maybe somon else here knows it

-- 
 [ signature omitted ] 

Message 8 in thread

Arvid Ephraim Picciani wrote:
> On Tuesday 08 April 2008 18:58:43 you wrote:
>
>   
>> Perhaps I should report that to fix as a wish to trolltech.
>>     
> not really a Qt bug. thats how windows pipes work afaik.
> tried using stderr?
> there is some flag that eneables stdout, maybe somon else here knows it
>
>   

The following works for me:

Volker Hilsheimer wrote:
>> Add following lines into main :
>>
>>
>> #ifdef WIN32
>>  AllocConsole();
>>  freopen("conin$", "r", stdin);
>>  freopen("conout$", "w", stdout);
>>  freopen("conout$", "w", stderr);
>> #endif
>>
>>
>> Regards,
>> Igor
>>
>>     
>
> That, or add CONFIG+=console to your .pro file.
>
> --
> Volker
>
> --
> List archive and information: http://qt-interest.trolltech.com
>   

--
 [ signature omitted ] 

Message 9 in thread

great, i missed that, thanks!


On Tuesday 08 April 2008 23:58:01 Pavel Koshevoy wrote:
> The following works for me:
>
> Volker Hilsheimer wrote:
> >> Add following lines into main :
> >>
> >>
> >> #ifdef WIN32
> >>  AllocConsole();
> >>  freopen("conin$", "r", stdin);
> >>  freopen("conout$", "w", stdout);
> >>  freopen("conout$", "w", stderr);
> >> #endif
> >>
> >>
> >> Regards,
> >> Igor
> >
> > That, or add CONFIG+=console to your .pro file.
> >
> > --
> > Volker
> >
> > --
> > List archive and information: http://qt-interest.trolltech.com
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body. List archive and information:
> http://lists.trolltech.com/qt-interest/



-- 
 [ signature omitted ] 

Message 10 in thread

These are good news, thanks:

#ifdef WIN32
   AllocConsole();
   freopen("conin$", "r", stdin);
   freopen("conout$", "w", stdout);
   freopen("conout$", "w", stderr);
#endif



Pavel Koshevoy schrieb:
> Arvid Ephraim Picciani wrote:
>> On Tuesday 08 April 2008 18:58:43 you wrote:
>>
>>  
>>> Perhaps I should report that to fix as a wish to trolltech.
>>>     
>> not really a Qt bug. thats how windows pipes work afaik.
>> tried using stderr?
>> there is some flag that eneables stdout, maybe somon else here knows it
>>
>>   
> 
> The following works for me:
> 
> Volker Hilsheimer wrote:
>>> Add following lines into main :
>>>
>>>
>>> #ifdef WIN32
>>>  AllocConsole();
>>>  freopen("conin$", "r", stdin);
>>>  freopen("conout$", "w", stdout);
>>>  freopen("conout$", "w", stderr);
>>> #endif
>>>
>>>
>>> Regards,
>>> Igor
>>>
>>>     
>>
>> That, or add CONFIG+=console to your .pro file.
>>
>> -- 
>> Volker
>>
>> -- 
>> List archive and information: http://qt-interest.trolltech.com
>>   
> 
> -- 
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
> 

--
 [ signature omitted ]