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. Supress warnings/errors from Qt classes?
Forum Updated to NodeBB v4.3 + New Features

Supress warnings/errors from Qt classes?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 5 Posters 959 Views 3 Watching
  • 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.
  • T Offline
    T Offline
    Taytoo
    wrote on last edited by
    #1

    In my code I sometimes see warnings/errors from Qt classes - some of which I have no control over e.g .if I check that a socket is open and start writing to it, but underlying socket closes during that time, it will result in an ERROR entry in the log file. Similarly, if a png file is loaded with invalid profile, it will generate a invalid RGB profile warning.

    Even though program isn't affected by it, I want to suppress these errors without completely disabling logging in my project. Is there a way to suppress Errors/Warnings for specific or all Qt classes?

    JonBJ 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Not that i have seen.
      You can redirect qDebug/QWarning etc and also disable it , but not
      as on a pr class basic as far as i know.

      1 Reply Last reply
      1
      • T Taytoo

        In my code I sometimes see warnings/errors from Qt classes - some of which I have no control over e.g .if I check that a socket is open and start writing to it, but underlying socket closes during that time, it will result in an ERROR entry in the log file. Similarly, if a png file is loaded with invalid profile, it will generate a invalid RGB profile warning.

        Even though program isn't affected by it, I want to suppress these errors without completely disabling logging in my project. Is there a way to suppress Errors/Warnings for specific or all Qt classes?

        JonBJ Online
        JonBJ Online
        JonB
        wrote on last edited by JonB
        #3

        @Taytoo
        You may be able to achieve what you want.

        Look at https://doc.qt.io/qt-5/qtglobal.html#qInstallMessageHandler. All [most! well-behaved!] messages go through here, including qDebug() etc. Although you cannot do something like "suppress messages from certain classes" --- the class issuing a message isn't even passed around as a parameter --- you might be prepared to recognise certain message texts and chose not to output them. That's the best you can do, which is what @mrjj was referring to with "You can redirect qDebug/QWarning etc".

        1 Reply Last reply
        2
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          One thing to take into account is that not all these warming and errors come from Qt. For example the png message comes from libpng directly.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          T 1 Reply Last reply
          2
          • SGaistS SGaist

            Hi,

            One thing to take into account is that not all these warming and errors come from Qt. For example the png message comes from libpng directly.

            T Offline
            T Offline
            Taytoo
            wrote on last edited by
            #5

            @mrjj I already have a messagehandler that I use to write logs in custom format. Thought about filtering string in there but it'll add too much overhead comparing each string that's being written to log.

            @SGaist True about libpng, but that's just warning and is written only when the image is loaded, however, socket error is written out each time a socket closes unexpectedly while i'm writing to it. The error makes it look like something went really wrong but its just a benign message.

            1 Reply Last reply
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Use categeorized logging für your logs and all which has no category can be ignored.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              4

              • Login

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