PDA

View Full Version : Program result writed by qDebug() to file doesn't work.



Vincenzo
19th March 2009, 19:17
Hi,

If i want write result of program to a file (Linux), i use the following command:
./prog > file.txt

It saves only those lines where i use the std::cout in source, but if i use the qDebug() this doesn't save anything at all. Suprisingly in command line both of them works without any problem. Of course i can use the first one, but it's odd.

Any suggestion?

spirit
19th March 2009, 19:30
you need to set you own message handler for qDebug. read this (http://www.qtcentre.org/forum/f-qt-programming-2/t-redirect-qdebug-to-file-19534.html/?highlight=qDebug). but in this thread discussed redirecting to a file, but you can redirect in std::out.

wysota
19th March 2009, 19:49
qDebug() outputs to std::err not std::out so you have to redirect the other descriptor. Try this:

./prog 2> file.txt