11

I am writing a simple OpenGL program with Qt Creator which basically creates a QGLWidget, shows it, and runs the application loop. I usually like debugging more with diagnostic messages turned on and off by preprocessor symbols that using an actual debugger and watches etc. In Qt Creator we have a tab called Application Output, but all I see there is "Starting xxx.exe. xxx.exe exited with code 0". No output from either std::cout or std::cerr. Now I know I could start my application from cmd.exe (yes, I am using Windows, love it :P) and see the output there but I wish I could see the output directly from the IDE. Is that possible? Thanks

Armen Tsirunyan
  • 130,161
  • 59
  • 324
  • 434

5 Answers5

11

Usually the Application Output pane works fine. Are you sure that you would see the output from cmd.exe (have you actually tried?)? It's usually turned off for UI applications to avoid console windows from popping up. Try CONFIG += console. Also check if you see qDebug() messages in the Application Output.

Frank Osterfeld
  • 24,815
  • 5
  • 58
  • 70
  • in linux I have the experience that all console output is shown, in Windows only qDebug will consistently show up in the window. – rubenvb Nov 13 '10 at 11:24
  • If your program prints a lot of output in qtcreator, it will hang for long periods of time after killing or exiting the debugger target. Some asinine algorithms in qtcreator's UI cause exponential execution time increase based on the number of lines of output. It has been like that for years. – doug65536 Apr 18 '16 at 22:51
  • Don't believe it? Try `int main() { while(1) std::cout << "Test" << std::endl; }`, let that run for a few minutes, and try to break into or kill the program. YMMV. – doug65536 Apr 18 '16 at 22:53
6

simply #include <QDebug> and then use qDebug instead of cout like

qDebug() << "you just clicked ok";

also this works

#include <QTextStream>
QTextStream out(stdout);
out << "\nHello World!\n";

adding CONFIG += console in the .pro file didn't work for me. I wonder why?

i just discovered that i've to add "endl;" for cout to work like

cout << "print this" << endl;
David Okwii
  • 7,352
  • 2
  • 36
  • 29
4

Alternatively, you can check the "run in console" setting in the Project->Run options. This will open a new console window and display all console output there (if CONFIG += console is used of course).

rubenvb
  • 74,642
  • 33
  • 187
  • 332
3

I know that this answer do not answer the original question, but since when searching for "No application output" we found this answer...

See the following answer: https://stackoverflow.com/a/26325743/808101 This only apply to qDebug() and similar functions (not direct output to stdout/stderr). In my case, I have to set QT_ASSUME_STDERR_HAS_CONSOLE environment variable to 1 in QtCreator in order to see qDebug() messages inside "Application Output" window.

benjarobin
  • 4,410
  • 27
  • 21
2

Try: Tools -> Options Under the "General" tab of "Environment" change the terminal entry from:

    x-terminal-emulator -e 

to

    xterm -e
DSUK
  • 274
  • 3
  • 13