Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stdout/cout from application launched from qt creator?

Tags:

qt4

qt-creator

I've been learning qt on windows for a little while (background in unix/embedded) and would like to have stderr/stdout dumped out somewhere (unit test/event logging/debug) from my win32 qt GUI app. That seems to be a tall order in windows and I found this post on stackoverflow which explains why.

I find myself wondering why qt doesn't have a simple mechanism for performing some of the suggestions in the post for debug builds.

Does such a facility already exist in qt or am I left to roll my own (or find a syslog lib)?

like image 430
tim Avatar asked Aug 13 '09 18:08

tim


People also ask

How do you display output in Qt?

Output is available on the taskbar in all modes. You can view output in the following ways: Select the output view on the taskbar. Select Alt (Cmd on macOS) and the number of the view on the taskbar.


2 Answers

qDebug() and related functions are handy for that sort of thing - will get sent to the debugger (if you're using Qt Creator, that will pick those up easily!)

#include <QDebug>

qDebug() << "x is: " << x;
like image 146
Paul Dixon Avatar answered Sep 20 '22 06:09

Paul Dixon


You can always start your programs from the command line to see stdout output (cmd.exe). Also, like Paul Dixon said, by using qDebug() you should be able to see the output in the debugger.

#include <QDebug>
...
{
   ...
   int x = 5;
   qDebug() << "x is: " << x;
}
like image 30
nmuntz Avatar answered Sep 19 '22 06:09

nmuntz