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. qInstallMessageHandler not showing anything when in debug mode
Forum Update on Monday, May 27th 2025

qInstallMessageHandler not showing anything when in debug mode

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 753 Views
  • 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.
  • Q Offline
    Q Offline
    QtTester
    wrote on 19 May 2022, 02:04 last edited by QtTester
    #1

    Hi,all:
    platform: win10+5.14.1+vs2017. qtcreator 4.11/ 6.0.2
    with helper, qInstallMessageHandler runs fine when you run the app, but if you press F5 enter debug mode, it shows nothing. I have to uncomment :

    //qInstallMessageHandler()
    

    so it can show debug string again. why?
    good shown:
    微信截图_20220519095917.png

    bad shown in DEBUG MODE:
    微信截图_20220519095934.png

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hskoglund
      wrote on 20 May 2022, 06:35 last edited by
      #4

      Hi, I also use qInstallMessageHandler and I remember also having problems with debug output: inside Qt there is a check for recursive calls to a custom message handler (in case there's a qDebug() call inside your message handler for example) so I ended up calling the Win32 OutputDebugString() directly in my message handler, like this:

          ::OutputDebugStringA(qUtf8Printable(msg + "\n"));
      

      In Linux and on the Mac fprintf() and fflush() work fine, it's just Windows that needs this workaround. Maybe it can solve your problem too...

      Q 1 Reply Last reply 20 May 2022, 06:59
      2
      • Q Offline
        Q Offline
        QtTester
        wrote on 19 May 2022, 02:19 last edited by QtTester
        #2

        I also try GDB, if adding fflush(stderr), it outputs perfectly. but delay output if not adding fflush():
        Maybe this is a qc bug when using CDB ???

        微信截图_20220519100958.png

        微信截图_20220519101305.png

        Q 1 Reply Last reply 20 May 2022, 03:52
        0
        • Q QtTester
          19 May 2022, 02:19

          I also try GDB, if adding fflush(stderr), it outputs perfectly. but delay output if not adding fflush():
          Maybe this is a qc bug when using CDB ???

          微信截图_20220519100958.png

          微信截图_20220519101305.png

          Q Offline
          Q Offline
          QtTester
          wrote on 20 May 2022, 03:52 last edited by
          #3

          Anyone has this problem?

          1 Reply Last reply
          0
          • H Offline
            H Offline
            hskoglund
            wrote on 20 May 2022, 06:35 last edited by
            #4

            Hi, I also use qInstallMessageHandler and I remember also having problems with debug output: inside Qt there is a check for recursive calls to a custom message handler (in case there's a qDebug() call inside your message handler for example) so I ended up calling the Win32 OutputDebugString() directly in my message handler, like this:

                ::OutputDebugStringA(qUtf8Printable(msg + "\n"));
            

            In Linux and on the Mac fprintf() and fflush() work fine, it's just Windows that needs this workaround. Maybe it can solve your problem too...

            Q 1 Reply Last reply 20 May 2022, 06:59
            2
            • H hskoglund
              20 May 2022, 06:35

              Hi, I also use qInstallMessageHandler and I remember also having problems with debug output: inside Qt there is a check for recursive calls to a custom message handler (in case there's a qDebug() call inside your message handler for example) so I ended up calling the Win32 OutputDebugString() directly in my message handler, like this:

                  ::OutputDebugStringA(qUtf8Printable(msg + "\n"));
              

              In Linux and on the Mac fprintf() and fflush() work fine, it's just Windows that needs this workaround. Maybe it can solve your problem too...

              Q Offline
              Q Offline
              QtTester
              wrote on 20 May 2022, 06:59 last edited by
              #5

              @hskoglund Works for me, thank you. I confirm it is a qtctreator's BUG.

              1 Reply Last reply
              0

              2/5

              19 May 2022, 02:19

              • Login

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