You can replace cout with qDebug(),
Qt Code:
#include <QDebug> qDebug() << "Hello World";To copy to clipboard, switch view to plain text mode
The output will be showed in the Application Output.
You can replace cout with qDebug(),
Qt Code:
#include <QDebug> qDebug() << "Hello World";To copy to clipboard, switch view to plain text mode
The output will be showed in the Application Output.
No, that won't work either. All output is directed to stdout (or stderr), but a Qt Windows program never opens a console window unless you add a configuration option.
Add CONFIG += console in your .pro file
This will open a console window when you start your program.
If you use gui module, and include QApplication header, the output from qDebug() will be showed in the Application Output (in Qt Creator).
The problem is when you don't use event loop, console window will close immediately (when using Qt Creator). In windows, i usually add CONFIG += console in my .pro and the following line
Qt Code:
#include <iostream> #include <cstdlib> using namespace std; int main(int argc, char *argv[]) { cout << "Hello World!" << endl; system("PAUSE"); // <--- return 0; }To copy to clipboard, switch view to plain text mode
Last edited by saa7_go; 21st August 2010 at 07:31. Reason: updated contents
QTextStream can be used too.
Qt Code:
To copy to clipboard, switch view to plain text mode
thank you for your advice,it works out
Bookmarks