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. change qDebug display level at runtime after program startup

change qDebug display level at runtime after program startup

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 608 Views 1 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.
  • J Offline
    J Offline
    James Mark Chan
    wrote on last edited by
    #1

    Does anyone know if it is possible to change the display of statements of qDebug() duration execution as opposed to startup?

    https://stackoverflow.com/questions/28540571/how-to-enable-and-disable-qdebug-messages

    JonBJ 1 Reply Last reply
    0
    • J James Mark Chan

      Does anyone know if it is possible to change the display of statements of qDebug() duration execution as opposed to startup?

      https://stackoverflow.com/questions/28540571/how-to-enable-and-disable-qdebug-messages

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @James-Mark-Chan
      As described in the link you reference, all qDebug() statements go via https://doc.qt.io/qt-5/qtglobal.html#qInstallMessageHandler, where you can do whatever you like at runtime with appropriate code. What is it that you cannot achieve that way?

      1 Reply Last reply
      2
      • J Offline
        J Offline
        James Mark Chan
        wrote on last edited by
        #3

        Looks like calling qInstallMessageHandler(myMessageOutput); replaces the default message handler which I believe will work for us. I though it added a message handler in addition to the default one and the default one could be configured further in some way.

        JonBJ 1 Reply Last reply
        0
        • J James Mark Chan

          Looks like calling qInstallMessageHandler(myMessageOutput); replaces the default message handler which I believe will work for us. I though it added a message handler in addition to the default one and the default one could be configured further in some way.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @James-Mark-Chan
          You can indeed only have one message handler. Calling qInstallMessageHandler() replaces any current one. The docs state:

          Only one message handler can be defined, since this is usually done on an application-wide basis to control debug output.

          However, because the method returns a QtMessageHandler

          Installs a Qt message handler which has been defined previously. Returns a pointer to the previous message handler.

          [My bold.] That means if you had a current/previous one which you still wanted under whatever circumstances, save this returned pointer and use it from your newly-installed one to call the original code in addition/instead of/as appropriate.

          1 Reply Last reply
          2

          • Login

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