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. Question about QMessageLogContext and "category" member
Forum Update on Monday, May 27th 2025

Question about QMessageLogContext and "category" member

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 172 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.
  • R Offline
    R Offline
    Robert Hairgrove
    wrote on last edited by Robert Hairgrove
    #1

    (...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.

    JonBJ 1 Reply Last reply
    0
    • R 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 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.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @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.

      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