Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QT_DEBUG and #include <QDebug>
Forum Updated to NodeBB v4.3 + New Features

QT_DEBUG and #include <QDebug>

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 5 Posters 3.2k Views 4 Watching
  • 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.
  • F Offline
    F Offline
    fem_dev
    wrote on last edited by
    #1

    I would like to know if is a "good pratice" to include <QDebug> only in QT_DEBUG mode. Like

    #ifdef QT_DEBUG
    #include <QDebug>
    #endif
    

    Or Qt Creator IDE already include the <QDebug> library only in debug mode automatically.

    Thank you,

    aha_1980A 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      well, its fine if you really want it gone in Release mode.
      It's not removed and still active in Release. Creator do not alter includes.

      You can do
      CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT
      in the .pro file
      to disable qDebug()

      so if you combine that with #ifdef QT_DEBUG
      then i guess it would make sense.

      This is just my personal opinion and might not be universally accepted
      as best practice :)

      1 Reply Last reply
      5
      • F fem_dev

        I would like to know if is a "good pratice" to include <QDebug> only in QT_DEBUG mode. Like

        #ifdef QT_DEBUG
        #include <QDebug>
        #endif
        

        Or Qt Creator IDE already include the <QDebug> library only in debug mode automatically.

        Thank you,

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by aha_1980
        #3

        Hi @fem_dev,

        the very best you can do is to switch to categorized logging.

        With that, you can turn on and off the debug messages at runtime, even in a release build and even on your customers machine far away.

        Can be a lifesaver ;)

        Regards

        Qt has to stay free or it will die.

        1 Reply Last reply
        4
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @aha_1980
          hi
          For some reason, the link did not work for me. but it seems correct !?
          so just in case:
          blog.qt.io/blog/2014/03/11/qt-weekly-1-categorized-logging

          ODБOïO 1 Reply Last reply
          3
          • mrjjM mrjj

            @aha_1980
            hi
            For some reason, the link did not work for me. but it seems correct !?
            so just in case:
            blog.qt.io/blog/2014/03/11/qt-weekly-1-categorized-logging

            ODБOïO Offline
            ODБOïO Offline
            ODБOï
            wrote on last edited by ODБOï
            #5

            @mrjj said in QT_DEBUG and #include <QDebug>:

            seems correct !?

            yes, same for me
            it looks like forum Link feature is broken ?
            link

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              You are missing the https:// on front of the url.
              @LeLev I fixed the link.

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

              ODБOïO 1 Reply Last reply
              3
              • SGaistS SGaist

                You are missing the https:// on front of the url.
                @LeLev I fixed the link.

                ODБOïO Offline
                ODБOïO Offline
                ODБOï
                wrote on last edited by
                #7

                @SGaist true! i fixed also
                my bad

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved