qDebug not displaying anything
Solution 1
The solution is simple:
add CONFIG += console
to your .pro file and rebuild the whole project.
Solution 2
Solution for me, As stated in https://bugzilla.redhat.com/show_bug.cgi?id=1227295#c10 was :
- look for
qtlogging.ini
in/etc/xdg/QtProject/
. - edit the current (or create the file
qtlogging.ini
if missing)
[Rules] *.debug=false
to
[Rules] *.debug=true qt.*.debug=false
- recompile and check!
Solution 3
If you are running multiple instances of Qt Creator, qDebug does not work properly.
Solution 4
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".
Solution 5
My solution for this problem using
Windows 10 Education
Qt Creator (5.x)
Developing a Qt widget.
Problem:
So my issue was whenever I added a QDebug
message it didn't show up in the application output although my code was 100% the same as in the tutorial and compiled fine.
Solution:
Right click on the file where you added the QDebug
message, for me it was main.cpp
. Click build. Press the green arrow on the bottom.
If this still doesn't work go to "Build"->"CleanAll", "Build"->"qMake" and go for the green arrow again.
Of course you have to #include <QDebug>
and check that it is well spelled inside your code.
Lukasz Czerwinski
My LinkedIn profile My email is: <my last name>.<my first name>[email protected]
Updated on October 21, 2021Comments
-
Lukasz Czerwinski over 2 years
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 ofqDebug()
isn't displayed at all! The same withqWarning
andqCritical
. What's strange, it only occurs when running the project normally (Ctrl+R), while when debugging (F5) the output shows up. -
Mayank about 11 yearsits not working for me...I used the statement
qDebug("test");
and addedCONFIG += console
to my .pro file. -
Lukasz Czerwinski about 11 yearsDid you try to rebuild the whole project? It worked for me then.
-
bobbaluba about 10 years@LukaszCzerwinski I did this, and it didn't work for me either. My problem is slightly different from OP, though, as I don't see debug output in neither debugging mode nor regular run.
-
Pandrei about 9 yearsmaybe off topic, but why are you answering your own question? :)
-
Lukasz Czerwinski about 9 yearsThat's a good question. I answered it because... Stackoverflow encourages people to do so (yes! :) )
-
Lukasz Czerwinski about 9 years1. There is a checkbox "Answer your own question" when you write the question (see: stackoverflow.com/questions/ask)
-
Lukasz Czerwinski about 9 years2. They also explicitly say that "It’s OK to Ask and Answer Your Own Questions" (see their blog: blog.stackoverflow.com/2011/07/…)
-
Lukasz Czerwinski about 9 yearsHTH. Happy stackoverflowing! :)
-
recycler over 5 yearsis working for me - seems that this entry is disabling the QDebug in recent systems like ubuntu 18.xx
-
Nicolas C. R. over 5 yearsim not sure if thats the cause, but i forgot to mention that i was on Ubuntu 17.10 and Qt 5.9
-
user240515 about 4 yearsAlso works if I put it in ~/.config/QtProject/qtlogging.ini
-
Som Pra about 4 yearsThe #include <QDebug> helped me... Thanks
-
Damon Jenkins almost 2 yearsThankyou so much omg