Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Changing debug log level



  • Is there any way, preferably from QML, to change the debug log level to suppress harmless warnings? I've got some QML GridLayout stuff that complains about cells already being taken, and they're cluttering up the log when I'm trying to use the log for my own debugging.

    (FYI, GridLayout objects have a particular limitation when dealing with items that span multiple cells, which I was only able to work around by overlapping them with dummy items. So I can't accomplish the formatting I need without provoking these harmless but annoying warnings.)



  • @sierdzio Thanks. Using this in main.cpp:

    QLoggingCategory::setFilterRules("*.warning=false");

    suppresses the warnings, but allows my console.log stuff to come through. I'd like to be more specific, but it appears that qgridlayoutengine.cpp uses QWarning(), which implies the "default" category, so even if I change the wildcard to "default", it's probably still going to filter out most warnings I might get in the future. I wish there was a way to install a regex filter on the log output.


  • Moderators

    See logging category docs.


  • Qt Champions 2018

    @pderocco ,

    I think that only QML can't stop warning from library.
    In mixed C ++ and QML project case, it may be stop by adding QT_NO_WARNING_OUTPUT at CONFIG.
    http://doc.qt.io/qt-5/debug.html#warning-and-debugging-messages

    and additional information, I use original log output at "LoggingCategory QML Type" in QML.
    https://doc.qt.io/qt-5/qml-qtqml-loggingcategory.html



  • @sierdzio Thanks. Using this in main.cpp:

    QLoggingCategory::setFilterRules("*.warning=false");

    suppresses the warnings, but allows my console.log stuff to come through. I'd like to be more specific, but it appears that qgridlayoutengine.cpp uses QWarning(), which implies the "default" category, so even if I change the wildcard to "default", it's probably still going to filter out most warnings I might get in the future. I wish there was a way to install a regex filter on the log output.


  • Moderators

    You can install your own filter (see next section under my link), but that will be cumbersome.

    Or you can patch your Qt sources and insert a logging category in that file, then filter it out.

    It would also be good to fix this upstream - feel invited to open a bug report for last of category in layout engine.


Log in to reply