0

I am currently using VS2010 (with Qt addin). I have run the Hello World Qt example and it works. I get a window where "Hello world" is written. But I can't see the command.exe window. When I use:

std::cout << "Windows command test!" << std::endl;

Nothing happens, why is it so?

MarAja
  • 1,547
  • 4
  • 20
  • 36

3 Answers3

1

Because you are using wrong project template.

The Hello world example that you have successfully built was using Qt Application project.

If you'd like to use the command prompt, open a Qt Console Application instead.

(picture is from google)

enter image description here

Tay2510
  • 5,748
  • 7
  • 39
  • 58
  • Ok, but if I want both: A Qt application and access to my console (for debugging for example). Should I choose a Qt Console Application? – MarAja Apr 17 '14 at 12:04
  • It's a very good question. [Windows seems to not support both mode at the same time](http://stackoverflow.com/questions/3360548/console-output-in-a-qt-gui-app) so I don't have a good answer for you at this moment, but you can take a look at [this thread](http://www.qtcentre.org/threads/38171-Both-a-command-line-and-GUI-application-at-the-same-time) (**check the reply of #7**). – Tay2510 Apr 17 '14 at 14:33
0

Unless Qt is eating your stdout, it should still be appearing, but it might be appearing and going away so fast that you do not see it. Take a look at this discussion for how to catch it.

Donald Duck
  • 8,409
  • 22
  • 75
  • 99
merlin2011
  • 71,677
  • 44
  • 195
  • 329
0

You can try to run your program from a cmd.exe windows. This way you can catch all console prints and it never close.

Sardik
  • 63
  • 6