PDA

View Full Version : Any way to output values to some QT output ?



tonnot
27th September 2010, 11:38
Is it possible to make some 'cout' to some place sited at QTCreator ?
In case of not, can I create a console window to do this ? (in a QT gui application)
Any idea ?
Thanks

baluk
27th September 2010, 11:47
Hi tonnot,
You don't have to create a console. Just use qDebug << "output" ; it will print the data to "Application Output" window which usually shows you the errors in the app. Also include #include <QDebug> library before using the command.

Baluk

tonnot
27th September 2010, 11:49
Ok. Thank you.
And what happens when I compile my exe and I give it to my client ?

baluk
27th September 2010, 12:01
You can't show him the output window. It is for developer sake to check the application is fine. When it is handed to client you can only show him the output on the GUI by using some "Label" widget etc. .

Baluk

nish
27th September 2010, 12:07
if i remember correctly ... there is a qmake value "QT += console" or something. But i haven't tried that.

Astronomy
27th September 2010, 12:39
Hi,
this is very simple. Just write:

include <iostream>;
using namespace std;

write:

cout << doubleVariable << endl;

In Qt: switch to application output, this will be the result which will be shown in a linux or dos console.


greetz A.

tbscope
27th September 2010, 12:44
Ok. Thank you.
And what happens when I compile my exe and I give it to my client ?

In release mode, qDebug() will not output anything.

tbscope
27th September 2010, 12:45
if i remember correctly ... there is a qmake value "QT += console" or something. But i haven't tried that.
That's important on Windows.

Better operating systems don't need this :-)

Lesiok
27th September 2010, 15:10
Just read about message handler (http://doc.trolltech.com/4.6/qtglobal.html#qInstallMsgHandler).