qDebug not displaying anything

20,430

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 :

  1. look for qtlogging.ini in /etc/xdg/QtProject/ .
  2. edit the current (or create the file qtlogging.ini if missing)
[Rules]
*.debug=false

to

[Rules]
*.debug=true
qt.*.debug=false
  1. 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.

Share:
20,430
Lukasz Czerwinski
Author by

Lukasz Czerwinski

My LinkedIn profile My email is: &lt;my last name&gt;.&lt;my first name&gt;[email protected]

Updated on October 21, 2021

Comments

  • Lukasz Czerwinski
    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 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.

  • Mayank
    Mayank about 11 years
    its not working for me...I used the statement qDebug("test"); and added CONFIG += console to my .pro file.
  • Lukasz Czerwinski
    Lukasz Czerwinski about 11 years
    Did you try to rebuild the whole project? It worked for me then.
  • bobbaluba
    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
    Pandrei about 9 years
    maybe off topic, but why are you answering your own question? :)
  • Lukasz Czerwinski
    Lukasz Czerwinski about 9 years
    That's a good question. I answered it because... Stackoverflow encourages people to do so (yes! :) )
  • Lukasz Czerwinski
    Lukasz Czerwinski about 9 years
    1. There is a checkbox "Answer your own question" when you write the question (see: stackoverflow.com/questions/ask)
  • Lukasz Czerwinski
    Lukasz Czerwinski about 9 years
    2. 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
    Lukasz Czerwinski about 9 years
    HTH. Happy stackoverflowing! :)
  • recycler
    recycler over 5 years
    is working for me - seems that this entry is disabling the QDebug in recent systems like ubuntu 18.xx
  • Nicolas C. R.
    Nicolas C. R. over 5 years
    im not sure if thats the cause, but i forgot to mention that i was on Ubuntu 17.10 and Qt 5.9
  • user240515
    user240515 about 4 years
    Also works if I put it in ~/.config/QtProject/qtlogging.ini
  • Som Pra
    Som Pra about 4 years
    The #include <QDebug> helped me... Thanks
  • Damon Jenkins
    Damon Jenkins almost 2 years
    Thankyou so much omg