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.
 
    
    - 8,109
- 3
- 36
- 48
 
    
    - 13,499
- 10
- 55
- 65
9 Answers
The solution is simple: 
add CONFIG += console to your .pro file and rebuild the whole project.
 
    
    - 13,499
- 10
- 55
- 65
- 
                    7its not working for me...I used the statement `qDebug("test");` and added `CONFIG += console` to my .pro file. – Mayank Apr 15 '13 at 10:43
- 
                    Did you try to *rebuild* the whole project? It worked for me then. – Lukasz Czerwinski Apr 29 '13 at 11:44
- 
                    3@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. – bobbaluba Mar 10 '14 at 00:01
- 
                    maybe off topic, but why are you answering your own question? :) – Pandrei Apr 01 '15 at 15:22
- 
                    1That's a good question. I answered it because... Stackoverflow encourages people to do so (yes! :) ) – Lukasz Czerwinski Apr 03 '15 at 17:26
- 
                    1. There is a checkbox "Answer your own question" when you write the question (see: http://stackoverflow.com/questions/ask) – Lukasz Czerwinski Apr 03 '15 at 17:27
- 
                    2. They also explicitly say that "It’s OK to Ask and Answer Your Own Questions" (see their blog: http://blog.stackoverflow.com/2011/07/its-ok-to-ask-and-answer-your-own-questions/) – Lukasz Czerwinski Apr 03 '15 at 17:28
- 
                    HTH. Happy stackoverflowing! :) – Lukasz Czerwinski Apr 03 '15 at 17:28
Solution for me, As stated in https://bugzilla.redhat.com/show_bug.cgi?id=1227295#c10 was :
- look for qtlogging.iniin/etc/xdg/QtProject/.
- edit the current (or create the file qtlogging.iniif missing)
[Rules] *.debug=false
to
[Rules] *.debug=true qt.*.debug=false
- recompile and check!
 
    
    - 10,380
- 6
- 51
- 102
 
    
    - 111
- 1
- 5
- 
                    is working for me - seems that this entry is disabling the QDebug in recent systems like ubuntu 18.xx – recycler Sep 21 '18 at 22:56
- 
                    im not sure if thats the cause, but i forgot to mention that i was on Ubuntu 17.10 and Qt 5.9 – Nicolas C. R. Sep 24 '18 at 12:53
- 
                    
If you are running multiple instances of Qt Creator, qDebug does not work properly.
 
    
    - 686
- 8
- 11
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/kde@lists.fedoraproject.org/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".
 
    
    - 471
- 5
- 13
- 
                    Took me hours to get here. I used Qt to crosscompile for windows 10, but qDebug did not display anything. I was using cLion as the IDE as Qt environment does not fit me. Using the above in Qt Widget application fixed this. – MuseumPiece Mar 23 '23 at 18:34
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.
 
    
    - 8,109
- 3
- 36
- 48
 
    
    - 1,877
- 1
- 21
- 23
In my case, it is somehow I forgot to click the 'Configure Project'. I am using QTCreator 4.11 and Qt5.14. When I create the project, I did not click on the 'Configure project' near the end of the creation process.
 
    
    - 21
- 2
Qt5.14.2, QtCreator 4.12.0: What worked for me was to unselect Projects->Run->Run in Terminal... Duh!
 
    
    - 63
- 10
You have to configure the logging rules. See documentation.
The format is:
    <category>[.<type>] = true|false
Logging rules are automatically loaded from the [Rules] section in a logging configuration file. These configuration files are looked up in the QtProject configuration directory, or explicitly set in a QT_LOGGING_CONF environment variable:
    [Rules]
    *.debug=false
    driver.usb.debug=true
Logging rules can also be specified in a QT_LOGGING_RULES environment variable; multiple rules can also be separated by semicolons:
    QT_LOGGING_RULES="*.debug=false;driver.usb.debug=true"
For example:
QT_LOGGING_RULES="*.debug=true;qt.*=false"
 
    
    - 65,406
- 61
- 242
- 386
Solved by adding:
export QT_ASSUME_STDERR_HAS_CONSOLE=1
to qtcreator start script placed in:
/home/yourUsername/qtcreator-10.0.0/bin/qtcreator.sh
provided by application downloaded from official site.
#! /bin/sh
export QT_ASSUME_STDERR_HAS_CONSOLE=1
# Use this script if you add paths to LD_LIBRARY_PATH
# that contain libraries that conflict with the
# libraries that Qt Creator depends on.
makeAbsolute() {
    case $1 in
        /*)
            # already absolute, return it
            echo "$1"
            ;;
        *)
            # relative, prepend $2 made absolute
            echo `makeAbsolute "$2" "$PWD"`/"$1" | sed 's,/\.$,,'
            ;;
    esac
}
..
//some lines...
..
export LD_LIBRARY_PATH
exec "$bindir/qtcreator" -user-library-path "$_ORIGINAL_LD_LIBRARY_PATH" ${1+"$@"}.
Update: Above solution is valid for Qt Creator. Using a terminal like xterm for starting, detached, a Qt application that use QProcess class for starting another Qt application (in my case in a project with more than one subprojects), readyReadStandardError() signal in the first one get correctly stderr of the second until terminal is closed when communication between processes broken. I solved this second problem adding
     qputenv("QT_ASSUME_STDERR_HAS_CONSOLE", "1");
in main.cpp so:
    #include "frmparman.h"
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        qputenv("QT_ASSUME_STDERR_HAS_CONSOLE", "1");
        a.setStyle("windows");
        frmParman w;
        w.show();
    
        return a.exec();
    }
 
    
    - 1
- 1