Important: Please read the Qt Code of Conduct -

[SOLVED] custom message handler with dlls

  • Hi all,
    I'm writing a GUI which calls some dlls. Super.
    I'm using qDebug messages in the dlls and in the GUI. They work just fine, with messages appearing in the QT creator output window from the dlls and from the GUI.

    Now, I installed a custom message handler in the GUI. This works fine for the qDebug messages arising from the GUI, but the qDebug messages from the dlls do not appear. Is there some way I can route the qDebug messages from the dlls to the custom handler?


  • I think I found the solution...

    It occurred to me that perhaps the dlls were being loaded at startup, and then just after that at the start of my main function the custom message handler was being installed. Maybe if I could get the message handler installed before the dlls were loaded it would work?

    So I removed the libs entry in the .pro file and loaded them after the custom message handler was installed in the program using QLibrary. When I do this the qDebug messages from the dll do come through to the message handler.

    Success. Although the resulting solution isn't as neat as just including the dlls in the .pro file. Though maybe it's a good thing as I can now add error handlers for if the dlls are not found.


Log in to reply