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
问题:
回答1:
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.
回答2:
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;
回答3:
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).
回答4:
Try: Tools -> Options Under the "General" tab of "Environment" change the terminal entry from:
x-terminal-emulator -e
to
xterm -e