Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

qDebug not displaying anything

Often when I need to debug something it's easier to print something using qDebug() instead of debugging step-by-step using a debugger. The problem is that from time to time the output of qDebug() isn't displayed at all! The same with qWarning and qCritical. What's strange, it only occurs when running the project normally (Ctrl+R), while when debugging (F5) the output shows up.

like image 607
Lukasz Czerwinski Avatar asked Oct 09 '12 12:10

Lukasz Czerwinski


3 Answers

I had the same problem and none of the answers here did help me. I found the solution here: https://lists.fedoraproject.org/archives/list/[email protected]/thread/SB6QJZGVDLWWBZCMTNKMVZSSPPNREOYJ/

I had to set QT_ASSUME_STDERR_HAS_CONSOLE=1. This can be done in code:

qputenv("QT_ASSUME_STDERR_HAS_CONSOLE", "1");

Or better in the "Kits" settings under "Environment".

like image 133
Mr. Clear Avatar answered Oct 13 '22 01:10

Mr. Clear


The solution is simple: add CONFIG += console to your .pro file and rebuild the whole project.

like image 29
Lukasz Czerwinski Avatar answered Oct 13 '22 02:10

Lukasz Czerwinski


If you are running multiple instances of Qt Creator, qDebug does not work properly.

like image 35
nandan Avatar answered Oct 13 '22 03:10

nandan