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. All .h files have a warning for Q_OBJECT

All .h files have a warning for Q_OBJECT

Scheduled Pinned Locked Moved Solved General and Desktop
16 Posts 6 Posters 5.8k Views 4 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #6

    ok so it sounds like your
    Qt installation was damaged somehow.

    When did it start ?
    Did you upgrade Qt version or how/when did error start to come?

    G 1 Reply Last reply
    0
    • G Offline
      G Offline
      gabor53
      wrote on last edited by
      #7

      It started when I added a few components to the installation. I guess I have to teinstall Qt.

      1 Reply Last reply
      0
      • mrjjM mrjj

        ok so it sounds like your
        Qt installation was damaged somehow.

        When did it start ?
        Did you upgrade Qt version or how/when did error start to come?

        G Offline
        G Offline
        gabor53
        wrote on last edited by
        #8

        @mrjj

        I reinstalled Qt 5.8 several times. The latest is from the online installer. I still have the same error message. I'm running MinGW 32 bit. I tried several examples from Qt, but I keep getting the same error message. Any idea what is going on? Thank you.

        mrjjM 1 Reply Last reply
        0
        • G gabor53

          @mrjj

          I reinstalled Qt 5.8 several times. The latest is from the online installer. I still have the same error message. I'm running MinGW 32 bit. I tried several examples from Qt, but I keep getting the same error message. Any idea what is going on? Thank you.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #9

          @gabor53
          Hi
          Is Qt5.8 mingw the only Qt you have installed ?
          There is no other Qt or compiler installed ?

          I have never seen this error nor does google so I am bit lost on what it can be.
          Only clue is ClangCodeModel.
          Check is DISABLED at
          Help > About Plugins > C++ > ClangCodeModel

          1 Reply Last reply
          1
          • Chris KawaC Offline
            Chris KawaC Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on last edited by Chris Kawa
            #10

            It's a bug: QTCREATORBUG-17518.
            You don't need to disable clang model. To workaround go to Tools->Options->C++->Code Model, press Copy to create a custom config, add -Wno-unknown-pragmas to the config text, apply and restart QtCreator. The warning should go away.

            D 1 Reply Last reply
            3
            • G Offline
              G Offline
              gabor53
              wrote on last edited by
              #11

              I had to disable the ClangCodeModel to get rid of the warning. No other methods worked. Thank you for your help.

              1 Reply Last reply
              0
              • Chris KawaC Chris Kawa

                It's a bug: QTCREATORBUG-17518.
                You don't need to disable clang model. To workaround go to Tools->Options->C++->Code Model, press Copy to create a custom config, add -Wno-unknown-pragmas to the config text, apply and restart QtCreator. The warning should go away.

                D Offline
                D Offline
                deleted515
                wrote on last edited by
                #12

                @Chris-Kawa This helped me get rid of the warning. Thank you very much.

                1 Reply Last reply
                0
                • N Offline
                  N Offline
                  nslw
                  wrote on last edited by
                  #13

                  The workaround from @Chris-Kawa is not working for me properly.
                  First in Qt Creator 10.0.0 the path is Edit->Preferences->C++->Clangd->Build-system warnings.
                  Second it suppresses all diagnostics from the build system, that's why it's not showing the warning anymore.

                  The only workaround that I've found is to disable "-Wsuggest-override" completely from the clangd checks by editing .clangd file in the project root directory and adding there

                  CompileFlags:
                    Remove: [-Wsuggest-override]
                  
                  Chris KawaC 1 Reply Last reply
                  0
                  • N nslw

                    The workaround from @Chris-Kawa is not working for me properly.
                    First in Qt Creator 10.0.0 the path is Edit->Preferences->C++->Clangd->Build-system warnings.
                    Second it suppresses all diagnostics from the build system, that's why it's not showing the warning anymore.

                    The only workaround that I've found is to disable "-Wsuggest-override" completely from the clangd checks by editing .clangd file in the project root directory and adding there

                    CompileFlags:
                      Remove: [-Wsuggest-override]
                    
                    Chris KawaC Offline
                    Chris KawaC Offline
                    Chris Kawa
                    Lifetime Qt Champion
                    wrote on last edited by
                    #14

                    @nslw said:

                    The workaround from @Chris-Kawa is not working for me properly.

                    It's been 6 years. Things change ;)

                    In year 2023 go to Edit->Preferences->C++->Clangd->Build-system and make a copy of the "Build-system warnings" configuration. In its properties add -Wno-inconsistent-missing-override. This will disable this particular waning from clangd, but it will also come from the build system, so you have to disable it there too. How you do it will depend on your compiler and build tool. For example if you use qmake and gcc you can add QMAKE_CXXFLAGS += -Wno-inconsistent-missing-override in the .pro file.

                    N 1 Reply Last reply
                    2
                    • Chris KawaC Chris Kawa

                      @nslw said:

                      The workaround from @Chris-Kawa is not working for me properly.

                      It's been 6 years. Things change ;)

                      In year 2023 go to Edit->Preferences->C++->Clangd->Build-system and make a copy of the "Build-system warnings" configuration. In its properties add -Wno-inconsistent-missing-override. This will disable this particular waning from clangd, but it will also come from the build system, so you have to disable it there too. How you do it will depend on your compiler and build tool. For example if you use qmake and gcc you can add QMAKE_CXXFLAGS += -Wno-inconsistent-missing-override in the .pro file.

                      N Offline
                      N Offline
                      nslw
                      wrote on last edited by
                      #15

                      @Chris-Kawa said in All .h files have a warning for Q_OBJECT:

                      @nslw said:

                      The workaround from @Chris-Kawa is not working for me properly.

                      It's been 6 years. Things change ;)

                      This hasn't changed though ;) Your workaround still doesn't work for me, because the warning comes from -Wsuggest-override and not from -Winconsistent-missing-override. Adding -Wno-inconsistent-missing-override, as you suggest, doesn't help at all and just cripples clangd more, as it stops reporting inconsistent missing overrides.

                      I use CMake, and add

                      set(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -Wsuggest-override")
                      

                      but I have to disable it in clangd, as I described earlier. This fixes it for me in QtCreator. I get no warnings from -Wsuggest-override (bad), but I still get non-purposedly-hidden/overriden warnings from -Winconsistent-missing-override (good).

                      Chris KawaC 1 Reply Last reply
                      0
                      • N nslw

                        @Chris-Kawa said in All .h files have a warning for Q_OBJECT:

                        @nslw said:

                        The workaround from @Chris-Kawa is not working for me properly.

                        It's been 6 years. Things change ;)

                        This hasn't changed though ;) Your workaround still doesn't work for me, because the warning comes from -Wsuggest-override and not from -Winconsistent-missing-override. Adding -Wno-inconsistent-missing-override, as you suggest, doesn't help at all and just cripples clangd more, as it stops reporting inconsistent missing overrides.

                        I use CMake, and add

                        set(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -Wsuggest-override")
                        

                        but I have to disable it in clangd, as I described earlier. This fixes it for me in QtCreator. I get no warnings from -Wsuggest-override (bad), but I still get non-purposedly-hidden/overriden warnings from -Winconsistent-missing-override (good).

                        Chris KawaC Offline
                        Chris KawaC Offline
                        Chris Kawa
                        Lifetime Qt Champion
                        wrote on last edited by
                        #16

                        @nslw Then replace -Wno-inconsistent-missing-override with -Wno-suggest-override in the settings I mentioned.

                        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