Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved How to disable qDebug ?

    General and Desktop
    4
    7
    376
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      AnneRanch last edited by

      I am looking for suggestions on how / where to disable ALL qDebug outputs to "Application Output" view during "Run" .

      I found this in another forum - but changing the QT_LOGGING_RULES does not compile when placed in header file. ( sorry the new error message posted BEFORE build does not copy something about C++ requires type specifier )

      I did try to add same into main x.pro file in my "subdirs" project , it complied but did not stop qDebug from executing.

      #ifndef PROJECT_COMMON_INCLUDE_H
      #define PROJECT_COMMON_INCLUDE_H
      #include <QLoggingCategory>
      QT_LOGGING_RULES="*.debug=false"; thows C++ syntax error
      #endif // PROJECT_COMMON_INCLUDE_H

      J.Hilk 1 Reply Last reply Reply Quote 0
      • J.Hilk
        J.Hilk Moderators @AnneRanch last edited by

        @AnneRanch
        in your pro file add DEFINES += QT_NO_DEBUG_OUTPUT

        disables qDebug() output

        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

        Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        A 1 Reply Last reply Reply Quote 3
        • Christian Ehrlicher
          Christian Ehrlicher Lifetime Qt Champion last edited by

          @AnneRanch said in How to disable qDebug ?:

          QT_LOGGING_RULES="*.debug=false"; thows C++ syntax error

          How do you expect that this does compile at all?

          QT_LOGGING_RULES is an environment variable.

          Qt has to stay free or it will die.

          1 Reply Last reply Reply Quote 2
          • J.Hilk
            J.Hilk Moderators @AnneRanch last edited by

            @AnneRanch
            in your pro file add DEFINES += QT_NO_DEBUG_OUTPUT

            disables qDebug() output

            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

            Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            A 1 Reply Last reply Reply Quote 3
            • A
              AnneRanch @J.Hilk last edited by

              @J-Hilk Thanks Purfect , KISS and works .Just in case anybody is interested I found this after your post.
              https://forum.qt.io/topic/73314/why-does-this-defined-qt_no_debug_output-not-supress-the-qdebug

              1 Reply Last reply Reply Quote 1
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                Hi,

                Note that Qt categorized logging is a different beast that uses qCDebug and friends. They are the one you can use QT_LOGGING_RULES with.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                A 1 Reply Last reply Reply Quote 0
                • A
                  AnneRanch @SGaist last edited by

                  @SGaist said in How to disable qDebug ?:

                  Hi,

                  Note that Qt categorized logging is a different beast that uses qCDebug and friends. They are the one you can use QT_LOGGING_RULES with.

                  The article I read first did not make it clear if it works with module / class or make.

                  I am also looking at implementing
                  qSetMessagePattern(testPattern); // const QString &pattern)

                  which is ever harder to figure out .

                  And it also kills qDebug....

                  1 Reply Last reply Reply Quote 0
                  • SGaist
                    SGaist Lifetime Qt Champion last edited by

                    From the QLoggingCategory documentation:

                    Logging rules can also be specified in a QT_LOGGING_RULES environment variable; multiple rules can also be separated by semicolons:
                    

                    It's an environment variable.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply Reply Quote 1
                    • First post
                      Last post