×

注意!页面内容来自https://forum.qt.io/topic/159213/qdebug-not-working,本站不储存任何内容,为了更好的阅读体验进行在线解析,若有广告出现,请及时反馈。若您觉得侵犯了您的利益,请通知我们进行删除,然后访问 原网页

Qt 6.11 is out! See what's new in the release blog

qDebug() not working.

Unsolved Installation and Deployment
12 4 4.5k 4
  • If this is in the wrong categoryfeel free to move it over.

    I recently installed a new fedora 40 os. I'm running cmake 3.28.2. (the default cmake in dnf.) Qt 6.7.2. On this computerI can not get qDebug() to print at all. Even just running cmake/make from the terminal doesn't get any reaction. qWarningand qInfo both work as expected.

    I move over to my "old" computerrunning Qt 6.7.0(installed through the online installer)and cmake 3.22.1. ThereqDebug() works correctly.

    Did something with cmake change in the last several releasessince 3.22? I've tried setting the configuration to debugetcand haven't gotten anywhere. The application compiles and runs correctlyjust no qDebug(). Code is here. https://github.com/Davidwedel/QtAgOpenGPS/tree/agio_dev

    Any advice will be much appreciated!

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

  • 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 uses qDebug() instead of that enormous project. Then you will know whether there is some issue with qDebug() 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 with QtDebugMsg.

  • 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. Thenwent to /usr/share/qt6/qtlogging.iniand set *.debug=true. Thenthe qDebug() logging worked correctly in the basic 4 line programas well as the QtMessageHandler when added to the 4 line program(by the waythe big project doesn't use QtMessageHandlerthough that might change :). But when I go to the big programthe 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(0x2456f2f0id="sensorsWindow"parent=0x2456ecf0geometry=0,0 0x80)
    qt.quick.layouts: "" QQuickGridLayoutBase::rearrange() QSizeF(080)
    qt.quick.layouts: LEAVE QQuickLayout::ensureLayoutItemsUpdated() QQuickRowLayout(0x2456f2f0)
    qt.quick.layouts: QQuickGridLayoutBase::rearrange 0 QQuickRowLayout(0x2456f2f0id="sensorsWindow"parent=0x2456ecf0geometry=0,0 0x80)
    

    I can disable this by setting *.debug=false but then I don't get any qDebug() logs. But nowthe console fills up much too fast to even read the logs I want.

  • 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. Thenwent to /usr/share/qt6/qtlogging.iniand set *.debug=true. Thenthe qDebug() logging worked correctly in the basic 4 line programas well as the QtMessageHandler when added to the 4 line program(by the waythe big project doesn't use QtMessageHandlerthough that might change :). But when I go to the big programthe 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(0x2456f2f0id="sensorsWindow"parent=0x2456ecf0geometry=0,0 0x80)
    qt.quick.layouts: "" QQuickGridLayoutBase::rearrange() QSizeF(080)
    qt.quick.layouts: LEAVE QQuickLayout::ensureLayoutItemsUpdated() QQuickRowLayout(0x2456f2f0)
    qt.quick.layouts: QQuickGridLayoutBase::rearrange 0 QQuickRowLayout(0x2456f2f0id="sensorsWindow"parent=0x2456ecf0geometry=0,0 0x80)
    

    I can disable this by setting *.debug=false but then I don't get any qDebug() logs. But nowthe 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(0x2456f2f0id="sensorsWindow"parent=0x2456ecf0geometry=0,0 0x80)
    qt.quick.layouts: "" QQuickGridLayoutBase::rearrange() QSizeF(080)
    qt.quick.layouts: LEAVE QQuickLayout::ensureLayoutItemsUpdated() QQuickRowLayout(0x2456f2f0)
    qt.quick.layouts: QQuickGridLayoutBase::rearrange 0 QQuickRowLayout(0x2456f2f0id="sensorsWindow"parent=0x2456ecf0geometry=0,0 0x80)
    

    I can disable this by setting *.debug=false but then I don't get any qDebug() logs. But nowthe 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 was qt.*.debug=false. I now see the qDebug() warningsbut not all the annoyinbg QT logs.
    So my qtlogging.ini looks like

    qt.*=false
    *.debug=true
    qt.*.debug=false
    qt.qpa.xcb.xcberror.warning=false
    

    Thanks againboth of you!

  • 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. Thenwent to /usr/share/qt6/qtlogging.iniand set *.debug=true. Thenthe qDebug() logging worked correctly in the basic 4 line programas well as the QtMessageHandler when added to the 4 line program(by the waythe big project doesn't use QtMessageHandlerthough that might change :). But when I go to the big programthe 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(0x2456f2f0id="sensorsWindow"parent=0x2456ecf0geometry=0,0 0x80)
    qt.quick.layouts: "" QQuickGridLayoutBase::rearrange() QSizeF(080)
    qt.quick.layouts: LEAVE QQuickLayout::ensureLayoutItemsUpdated() QQuickRowLayout(0x2456f2f0)
    qt.quick.layouts: QQuickGridLayoutBase::rearrange 0 QQuickRowLayout(0x2456f2f0id="sensorsWindow"parent=0x2456ecf0geometry=0,0 0x80)
    

    I can disable this by setting *.debug=false but then I don't get any qDebug() logs. But nowthe console fills up much too fast to even read the logs I want.

    @davidwedel said in qDebug() not working.:

    Thenwent to /usr/share/qt6/qtlogging.iniand set *.debug=true. Thenthe 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.ininor any qtlogging.ini file anywhere. It outputs qDebug() messages just fineas do all previous Ubuntu releaseswithout my having to create this or change anything. In your caseare you saying there was already a qtlogging.ini file with something inside it supplied with your Fedora?

  • @davidwedel said in qDebug() not working.:

    Thenwent to /usr/share/qt6/qtlogging.iniand set *.debug=true. Thenthe 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.ininor any qtlogging.ini file anywhere. It outputs qDebug() messages just fineas do all previous Ubuntu releaseswithout my having to create this or change anything. In your caseare you saying there was already a qtlogging.ini file with something inside it supplied with your Fedora?

    @JonB said in qDebug() not working.:

    In your caseare 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

  • @JonB said in qDebug() not working.:

    In your caseare 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? My qDebug()s have always worked finepresumably with that file always emptymaybe somebody put one in for some reason in whichever Mint distribution.

  • It had:

    [Rules]
    *.debug=false
    qt.qpa.xcb.xcberror.warning=false
    

    Interestingly enoughthis file is present on a completely fresh Fedora 40 computer. I booted up a live usb that hadn't had anything Qt related installedand there it was.

  • It had:

    [Rules]
    *.debug=false
    qt.qpa.xcb.xcberror.warning=false
    

    Interestingly enoughthis file is present on a completely fresh Fedora 40 computer. I booted up a live usb that hadn't had anything Qt related installedand 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 iteven if no Qt! :) Naughty Fedora people!

  • I've just come across exactly the same thing on Mageia. Has been driving me nuts!

    My ini file was identical to OP's.