Question about QMessageLogContext and "category" member

  • (...using Qt 5.12.9 on Ubuntu 18.04 and Windows 10...)

    I am using a third-party open source library as source code in my application, and have implemented a custom message handler for trapping warnings and errors. It appears that this library only issues qWarning messages which are actually errors.

    Is there a way to define a global category for the QMessageLogContext argument to enable warnings from this library and disable them for the rest of the application without checking the file name for each warning message in my message handler? I haven't tested this yet, but I assume that the category member of the QMessageLogContext argument will always be "default" if that library doesn't set it explicitly. Then the only way I can see to determine where the error or warning was raised would be by checking the file name. It's certainly possible to do it this way, but since I get warnings from other places as well, I would like to differentiate these, and using a different category seems like the way to do it.

  • @Robert-Hairgrove
    As you say, if the source of the library did not set any explicit category then you have nothing to start from other than the source filename.

Log in to reply