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.
qDebug not displaying anything
26.8k Views Asked by Lukasz Czerwinski AtThere are 9 best solutions below

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"

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!

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.

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();
}

Qt5.14.2, QtCreator 4.12.0: What worked for me was to unselect Projects->Run->Run in Terminal... Duh!

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.

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 the environment variable 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".
The solution is simple: add
CONFIG += console
to your .pro file and rebuild the whole project.