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. Subclassing QDebug to get rid of the NewLine of QDebug() function ?
Forum Updated to NodeBB v4.3 + New Features

Subclassing QDebug to get rid of the NewLine of QDebug() function ?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.8k 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.
  • U Offline
    U Offline
    u2gilles
    wrote on last edited by
    #1

    Does anyone here have even tried to subclass QDebug in a way that it does not send a Line Feel (“\n”) when it is destroyed? Is there a virtual function to reimplement in order to easily do it.
    Thanks in advance
    Gilles
    PS : I know I could use std::cout, but it does not display Qt Classes

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Instead of subclassing QDebug you can call qInstallMsgHandler(someHandlerFunc) and then chop the offending newline character in this handler and output it to wherever you want.

      This way you have full control over what and where is outputted but you get to keep the nice QDebug formatting.

      http://doc.qt.digia.com/qt/qtglobal.html#qInstallMsgHandler

      1 Reply Last reply
      0
      • U Offline
        U Offline
        u2gilles
        wrote on last edited by
        #3

        Thanks Krzystof. That's exactly what i needed.
        Adding in the message handler this :
        @
        case QtDebugMsg:
        std::cout << msg;
        break;
        @

        gave me the behavior i was looking for.

        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