qDebug() not working.
-
Update. I really don't know what to try next. I've edited the qtlogging.ini. I've tried to find the most basic QT/cpp applications online. Everything compiles and runs just fine. qWarning() and qInfo() work. But qDebug() will never show up.
std::cout << "etc";
seems to work just fine. -
@davidwedel
So start by writing a standalone 4 line program which usesqDebug()
instead of that enormous project. Then you will know whether there is some issue withqDebug()
itself or maybe the flags you use to compile. Assuming not then either there is something in your project's code or in the options/defines used to compile it.One thing you could check is whether your big project uses QtMessageHandler qInstallMessageHandler(QtMessageHandler handler). That can be used to handle/redirect output from
qDebug()
and the other related macros. It also mentions "QT_NO_DEBUG_OUTPUT
have been set during compilation", check that is not the case. If your code does not install a message handler do so now temporarily to see whether this is being called withQtDebugMsg
. -
OK so I got a few things figured out! I did indeed have QT_NO_DEBUG_OUTPUT (set to off I thought) in my CMakeLists.txt. Removed that. Still no joy. Then, went to /usr/share/qt6/qtlogging.ini, and set
*.debug=true
. Then, the qDebug() logging worked correctly in the basic 4 line program, as well as the QtMessageHandler when added to the 4 line program(by the way, the big project doesn't use QtMessageHandler, though that might change :). But when I go to the big program, the console is completely flooded with all kinds of debug info with all things Qt related. Here's a sample.qt.quick.layouts: QQuickGridLayoutBase::rearrange 0 QQuickRowLayout(0x2456f2f0, id="sensorsWindow", parent=0x2456ecf0, geometry=0,0 0x80) qt.quick.layouts: "" QQuickGridLayoutBase::rearrange() QSizeF(0, 80) qt.quick.layouts: LEAVE QQuickLayout::ensureLayoutItemsUpdated() QQuickRowLayout(0x2456f2f0) qt.quick.layouts: QQuickGridLayoutBase::rearrange 0 QQuickRowLayout(0x2456f2f0, id="sensorsWindow", parent=0x2456ecf0, geometry=0,0 0x80)
I can disable this by setting
*.debug=false
but then I don't get any qDebug() logs. But now, the console fills up much too fast to even read the logs I want. -
@davidwedel said in qDebug() not working.:
qt.quick.layouts: QQuickGridLayoutBase::rearrange 0 QQuickRowLayout(0x2456f2f0, id="sensorsWindow", parent=0x2456ecf0, geometry=0,0 0x80) qt.quick.layouts: "" QQuickGridLayoutBase::rearrange() QSizeF(0, 80) qt.quick.layouts: LEAVE QQuickLayout::ensureLayoutItemsUpdated() QQuickRowLayout(0x2456f2f0) qt.quick.layouts: QQuickGridLayoutBase::rearrange 0 QQuickRowLayout(0x2456f2f0, id="sensorsWindow", parent=0x2456ecf0, geometry=0,0 0x80)
I can disable this by setting
*.debug=false
but then I don't get any qDebug() logs. But now, the console fills up much too fast to even read the logs I want.qt.quick.layouts and similar are hierarchical logging categories that can be controlled. Eg
*.debug=true; qt.quick.*.debug=false;
-
Aha! Thanks @jeremy_k
The final answer wasqt.*.debug=false
. I now see the qDebug() warnings, but not all the annoyinbg QT logs.
So my qtlogging.ini looks likeqt.*=false *.debug=true qt.*.debug=false qt.qpa.xcb.xcberror.warning=false
Thanks again, both of you!
-
@davidwedel said in qDebug() not working.:
Then, went to /usr/share/qt6/qtlogging.ini, and set *.debug=true. Then, the qDebug() logging worked correctly
Just out of interest/for anyone else reading this. I have the default Qt6 (6.4.2) supplied with Ubuntu 24.04. There is no
/usr/share/qt6/qtlogging.ini
, nor anyqtlogging.ini
file anywhere. It outputsqDebug()
messages just fine, as do all previous Ubuntu releases, without my having to create this or change anything. In your case, are you saying there was already aqtlogging.ini
file with something inside it supplied with your Fedora? -
@JonB said in qDebug() not working.:
In your case, are you saying there was already a qtlogging.ini file with something inside it supplied with your Fedora?
That's correct. I didn't create it. That also explains why I could never find the qtlogging.ini file on my Mint 21.1 computer
-
@davidwedel
So what was inside it when you found it? MyqDebug()
s have always worked fine, presumably with that file always empty, maybe somebody put one in for some reason in whichever Mint distribution. -
It had:
[Rules] *.debug=false qt.qpa.xcb.xcberror.warning=false
Interestingly enough, this file is present on a completely fresh Fedora 40 computer. I booted up a live usb that hadn't had anything Qt related installed, and there it was.
-
@davidwedel
So it looks like maybe someone was playing with Qt and switched default debugging off and that's how it got released with this file in it, even if no Qt! :) Naughty Fedora people!