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. Disable specific warning in Qt Creator
Forum Updated to NodeBB v4.3 + New Features

Disable specific warning in Qt Creator

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 7.4k 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.
  • D Offline
    D Offline
    Donald Duck
    wrote on 8 Aug 2018, 03:12 last edited by Donald Duck 8 Aug 2018, 05:46
    #1

    Apparently the new version of Qt Creator checks for warnings while I'm writing the code. That's a nice feature, but I find some of the warnings more annoying than helpful. For example, one of the warnings I find most annoying is "enumeration values not handled in switch", since if I have a QMessageBox that only has 3 buttons it expects me to handle all 20 enumeration values even though I know that only 3 of those values are possible. For example I get a useless warning for the following code:

    switch(QMessageBox::warning(this, "", "Do you want to save the file before leaving?", QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel)){
    case QMessageBox::Yes:
        //Save and quit
        break;
    case QMessageBox::Cancel:
        //Don't quit
        break;
    case QMessageBox::No:
        //Quit
        break;
    }
    

    My question is how can I disable a certain type of warning in Qt Creator?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      Donald Duck
      wrote on 8 Aug 2018, 05:48 last edited by Donald Duck 8 Aug 2018, 17:32
      #2

      I found the solution. It's in Options > C++ > Code Model > Manage..., then press the "Copy" button. Then in the Clang tab, there will be a text area. If you type -w in the text area, it disables all warnings. To keep some of the warnings enabled, see here for what to put in there.

      1 Reply Last reply
      3
      • M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 8 Aug 2018, 16:56 last edited by
        #3

        Just as a note
        if you add default case, it stops warning.
        ...
        default:
        break;
        }

        1 Reply Last reply
        4
        • C Offline
          C Offline
          casperbear
          wrote on 31 Aug 2019, 14:52 last edited by casperbear
          #4

          It looks like you can construct a -Wno-... parameter even if it's not mentioned in https://clang.llvm.org/docs/DiagnosticsReference.html
          You can try to add -Wno-switch-enum in your specific case.

          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