Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Question about QMessageLogContext and "category" member
Robert Hairgrove last edited by Robert Hairgrove
(...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
qWarningmessages which are actually errors.
Is there a way to define a global category for the
QMessageLogContextargument 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
categorymember of the
QMessageLogContextargument 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.
JonB last edited by
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.