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. How to switch off specific warnings in Qt Creator
Forum Updated to NodeBB v4.3 + New Features

How to switch off specific warnings in Qt Creator

Scheduled Pinned Locked Moved Unsolved General and Desktop
15 Posts 3 Posters 97 Views 1 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
    DiBosco
    wrote last edited by DiBosco
    #1

    Folks,

    I am getting lots of depricated warnings (I cannot upgrade to a newer version of Qt BTW, so, for me, this is not going to be a solution I have seen suggested elsewhere). After doing loads of trawling around, the method seems to be to add to your .pro file:

    QMAKE_CXXFLAGS_WARN_OFF -= -Wdeprecated-copy
    

    However, this makes no an iota of difference.

    This is an example of a full warning message:

    /path/qtransform.h:376: warning: implicitly-declared ‘QTransform::QTransform(const QTransform&)’ is deprecated [-Wdeprecated-copy]
    In file included from /path//QtGui/qbrush.h:43,
                     from /path//qpalette.h:39,
                     from /path//qwidget.h:41,
                     from /path//QWidget:1,
                     from ../PI03SW05/crc.h:5,
                     from ../PI03SW05/crc.cpp:1:
    /path/qtransform.h: In function ‘QTransform operator*(const QTransform&, qreal)’:
    /path/qtransform.h:376:17: warning: implicitly-declared ‘QTransform::QTransform(const QTransform&)’ is deprecated [-Wdeprecated-copy]
      376 | { QTransform t(a); t *= n; return t; }
          |                 ^
    /path/qtransform.h:121:17: note: because ‘QTransform’ has user-provided ‘QTransform& QTransform::operator=(const QTransform&)’
      121 |     QTransform &operator=(const QTransform &);
    

    Anyone know what I am doing wrong here and (with explicit instructions) how to fix this please? Am using 5.6.3 on Linux FWIW.

    Thanks :)

    D JonBJ 2 Replies Last reply
    0
    • D DiBosco

      Folks,

      I am getting lots of depricated warnings (I cannot upgrade to a newer version of Qt BTW, so, for me, this is not going to be a solution I have seen suggested elsewhere). After doing loads of trawling around, the method seems to be to add to your .pro file:

      QMAKE_CXXFLAGS_WARN_OFF -= -Wdeprecated-copy
      

      However, this makes no an iota of difference.

      This is an example of a full warning message:

      /path/qtransform.h:376: warning: implicitly-declared ‘QTransform::QTransform(const QTransform&)’ is deprecated [-Wdeprecated-copy]
      In file included from /path//QtGui/qbrush.h:43,
                       from /path//qpalette.h:39,
                       from /path//qwidget.h:41,
                       from /path//QWidget:1,
                       from ../PI03SW05/crc.h:5,
                       from ../PI03SW05/crc.cpp:1:
      /path/qtransform.h: In function ‘QTransform operator*(const QTransform&, qreal)’:
      /path/qtransform.h:376:17: warning: implicitly-declared ‘QTransform::QTransform(const QTransform&)’ is deprecated [-Wdeprecated-copy]
        376 | { QTransform t(a); t *= n; return t; }
            |                 ^
      /path/qtransform.h:121:17: note: because ‘QTransform’ has user-provided ‘QTransform& QTransform::operator=(const QTransform&)’
        121 |     QTransform &operator=(const QTransform &);
      

      Anyone know what I am doing wrong here and (with explicit instructions) how to fix this please? Am using 5.6.3 on Linux FWIW.

      Thanks :)

      D Offline
      D Offline
      DiBosco
      wrote last edited by
      #2
      This post is deleted!
      D 1 Reply Last reply
      0
      • D DiBosco

        This post is deleted!

        D Offline
        D Offline
        DiBosco
        wrote last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • D DiBosco

          Folks,

          I am getting lots of depricated warnings (I cannot upgrade to a newer version of Qt BTW, so, for me, this is not going to be a solution I have seen suggested elsewhere). After doing loads of trawling around, the method seems to be to add to your .pro file:

          QMAKE_CXXFLAGS_WARN_OFF -= -Wdeprecated-copy
          

          However, this makes no an iota of difference.

          This is an example of a full warning message:

          /path/qtransform.h:376: warning: implicitly-declared ‘QTransform::QTransform(const QTransform&)’ is deprecated [-Wdeprecated-copy]
          In file included from /path//QtGui/qbrush.h:43,
                           from /path//qpalette.h:39,
                           from /path//qwidget.h:41,
                           from /path//QWidget:1,
                           from ../PI03SW05/crc.h:5,
                           from ../PI03SW05/crc.cpp:1:
          /path/qtransform.h: In function ‘QTransform operator*(const QTransform&, qreal)’:
          /path/qtransform.h:376:17: warning: implicitly-declared ‘QTransform::QTransform(const QTransform&)’ is deprecated [-Wdeprecated-copy]
            376 | { QTransform t(a); t *= n; return t; }
                |                 ^
          /path/qtransform.h:121:17: note: because ‘QTransform’ has user-provided ‘QTransform& QTransform::operator=(const QTransform&)’
            121 |     QTransform &operator=(const QTransform &);
          

          Anyone know what I am doing wrong here and (with explicit instructions) how to fix this please? Am using 5.6.3 on Linux FWIW.

          Thanks :)

          JonBJ Online
          JonBJ Online
          JonB
          wrote last edited by
          #4

          @DiBosco said in How to switch off specific warnings in Qt Creator:

          However, this makes no an iota of difference.

          According to https://forum.qt.io/post/649283 you should:

          Use CONFIG += warn_off in your .pro file to disable warnings. This will make sure the compiler is called with all the flags set in QMAKE_CXXFLAGS_WARN_OFF (which should be automatically set by the default mkspecs, so usually no reason to change it).

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DiBosco
            wrote last edited by
            #5

            Using CONFIG += warn_off switches of ALL warnings though and I don't want that.

            JonBJ 1 Reply Last reply
            0
            • D DiBosco

              Using CONFIG += warn_off switches of ALL warnings though and I don't want that.

              JonBJ Online
              JonBJ Online
              JonB
              wrote last edited by
              #6

              @DiBosco
              Did you actually try it though? I read the answer as indicating/suggesting that CONFIG += warn_off is required to make QMAKE_CXXFLAGS_WARN_OFF be taken into account? The OP there seemed to say same as you: setting QMAKE_CXXFLAGS_WARN_OFF alone did not have any effect.

              Try it to see if you can tell it makes a difference? Check the actual options being passed to the gcc in each case? Figure how to make QMAKE_CXXFLAGS_WARN_OFF actually affect things if it does it right from the CONFIG statement but not in your case?

              D 1 Reply Last reply
              0
              • JonBJ JonB

                @DiBosco
                Did you actually try it though? I read the answer as indicating/suggesting that CONFIG += warn_off is required to make QMAKE_CXXFLAGS_WARN_OFF be taken into account? The OP there seemed to say same as you: setting QMAKE_CXXFLAGS_WARN_OFF alone did not have any effect.

                Try it to see if you can tell it makes a difference? Check the actual options being passed to the gcc in each case? Figure how to make QMAKE_CXXFLAGS_WARN_OFF actually affect things if it does it right from the CONFIG statement but not in your case?

                D Offline
                D Offline
                DiBosco
                wrote last edited by
                #7

                @JonB Yes, that's how I know it suppresses all warnings :)

                If I put this in my .pro file:

                CONFIG += warn_off
                QMAKE_CXXFLAGS_WARN_OFF -= -Wdeprecated-copy
                

                No warnings at all. If I take out the:

                CONFIG += warn_off
                

                line then all warnings are present.

                JonBJ 1 Reply Last reply
                0
                • D DiBosco

                  @JonB Yes, that's how I know it suppresses all warnings :)

                  If I put this in my .pro file:

                  CONFIG += warn_off
                  QMAKE_CXXFLAGS_WARN_OFF -= -Wdeprecated-copy
                  

                  No warnings at all. If I take out the:

                  CONFIG += warn_off
                  

                  line then all warnings are present.

                  JonBJ Online
                  JonBJ Online
                  JonB
                  wrote last edited by JonB
                  #8

                  @DiBosco
                  I already suggested: you ought find out why (apparently, according to you and the other poster) that without CONFIG += warn_off setting QMAKE_CXXFLAGS_WARN_OFF -= -Wdeprecated-copy has no effect. Then maybe you will be able to remove CONFIG and know what you have to do to make QMAKE_CXXFLAGS_WARN_OFF -= -Wdeprecated-copy work on its own.

                  Not that I know anything about this, but I would guess that QMAKE_CXXFLAGS_WARN_OFF is only used at all if you have CONFIG += warn_off, i.e. the latter "activates" the former's flags to be used. Without that configuration QMAKE_CXXFLAGS_WARN_OFF is not passed to compiler. If you want -Wdeprecated-copy in other circumstances than with all other warnings turned off I would presume you should use another variable which is always passed to compiler. Something like QMAKE_CXXFLAGS? Does that satisfy you?

                  D 1 Reply Last reply
                  0
                  • JonBJ JonB

                    @DiBosco
                    I already suggested: you ought find out why (apparently, according to you and the other poster) that without CONFIG += warn_off setting QMAKE_CXXFLAGS_WARN_OFF -= -Wdeprecated-copy has no effect. Then maybe you will be able to remove CONFIG and know what you have to do to make QMAKE_CXXFLAGS_WARN_OFF -= -Wdeprecated-copy work on its own.

                    Not that I know anything about this, but I would guess that QMAKE_CXXFLAGS_WARN_OFF is only used at all if you have CONFIG += warn_off, i.e. the latter "activates" the former's flags to be used. Without that configuration QMAKE_CXXFLAGS_WARN_OFF is not passed to compiler. If you want -Wdeprecated-copy in other circumstances than with all other warnings turned off I would presume you should use another variable which is always passed to compiler. Something like QMAKE_CXXFLAGS? Does that satisfy you?

                    D Offline
                    D Offline
                    DiBosco
                    wrote last edited by
                    #9

                    @JonB

                    I'm not sure I've made it clear that with

                    CONFIG += warn_off
                    

                    All warnings go. So, for example, unused variables no long show up (which I want to see).

                    I want all deprecated warnings to go, but I want to see other types of warning.

                    D JonBJ 2 Replies Last reply
                    0
                    • D DiBosco

                      @JonB

                      I'm not sure I've made it clear that with

                      CONFIG += warn_off
                      

                      All warnings go. So, for example, unused variables no long show up (which I want to see).

                      I want all deprecated warnings to go, but I want to see other types of warning.

                      D Offline
                      D Offline
                      DiBosco
                      wrote last edited by
                      #10

                      @DiBosco said in How to switch off specific warnings in Qt Creator:

                      @JonB

                      I'm not sure I've made it clear that with

                      CONFIG += warn_off
                      

                      All warnings go. So, for example, unused variables no long show up (which I want to see).

                      I want all deprecated warnings to go, but I want to see other types of warning.

                      PS Trying to find out what I ought to do is what I'm doing here. I spent absolutely ages trawling round various sites such as here and Stack Overflow to no avail.

                      1 Reply Last reply
                      0
                      • D DiBosco

                        @JonB

                        I'm not sure I've made it clear that with

                        CONFIG += warn_off
                        

                        All warnings go. So, for example, unused variables no long show up (which I want to see).

                        I want all deprecated warnings to go, but I want to see other types of warning.

                        JonBJ Online
                        JonBJ Online
                        JonB
                        wrote last edited by
                        #11

                        @DiBosco said in How to switch off specific warnings in Qt Creator:

                        All warnings go. So, for example, unused variables no long show up (which I want to see).

                        I want all deprecated warnings to go, but I want to see other types of warning.

                        I know this. And I suggested why QMAKE_CXXFLAGS_WARN_OFF probably has no effect and precisely what you should do, which you apparently have not tried.....

                        D 1 Reply Last reply
                        0
                        • JonBJ JonB

                          @DiBosco said in How to switch off specific warnings in Qt Creator:

                          All warnings go. So, for example, unused variables no long show up (which I want to see).

                          I want all deprecated warnings to go, but I want to see other types of warning.

                          I know this. And I suggested why QMAKE_CXXFLAGS_WARN_OFF probably has no effect and precisely what you should do, which you apparently have not tried.....

                          D Offline
                          D Offline
                          DiBosco
                          wrote last edited by
                          #12

                          @JonB

                          I think I'm missing something here because I said a few posts up I tried:

                          CONFIG += warn_off
                          QMAKE_CXXFLAGS_WARN_OFF -= -Wdeprecated-copy
                          

                          So I have tried QMAKE_CXXFLAGS_WARN_OFF. Sorry if I'm being slow here, but if that's not what you mean I need something more explicit to try.

                          JonBJ 1 Reply Last reply
                          0
                          • aha_1980A Offline
                            aha_1980A Offline
                            aha_1980
                            Lifetime Qt Champion
                            wrote last edited by
                            #13

                            @DiBosco Have you already seen https://stackoverflow.com/questions/22129383/removing-unused-parameters-warning-in-qtcreator ?

                            For your case, it would be: QMAKE_CXXFLAGS_WARN_ON += -Wno-deprecated-copy

                            Regards

                            Qt has to stay free or it will die.

                            D 1 Reply Last reply
                            3
                            • D DiBosco

                              @JonB

                              I think I'm missing something here because I said a few posts up I tried:

                              CONFIG += warn_off
                              QMAKE_CXXFLAGS_WARN_OFF -= -Wdeprecated-copy
                              

                              So I have tried QMAKE_CXXFLAGS_WARN_OFF. Sorry if I'm being slow here, but if that's not what you mean I need something more explicit to try.

                              JonBJ Online
                              JonBJ Online
                              JonB
                              wrote last edited by JonB
                              #14

                              @DiBosco
                              :)

                              • Forget about CONFIG ..., remove it.
                              • Forget about QMAKE_CXXFLAGS_WARN_OFF ..., remove it.
                              • Try this:

                              If you want -Wdeprecated-copy in other circumstances than with all other warnings turned off I would presume you should use another variable which is always passed to compiler. Something like QMAKE_CXXFLAGS? Does that satisfy you?

                              I cannot be sure which one to use, but what happens if you add a line reading:

                              QMAKE_CXXFLAGS -= -Wdeprecated-copy
                              

                              If that does not work we (you!) need to understand what is adding -Wdeprecated-copy on the gcc compiler line (I asked you to look at the actual line being generated, does it have that option?) and then presumably something like THE_MACRO_WHICH_ADDED_IT -= -Wdeprecated-copy to remove it?

                              P.S.
                              Since @aha_1980 has just chimed in to say there is a QMAKE_CXXFLAGS_WARN_ON and a -Wno-deprecated-copy which can be added you should try that. If by any chance that does not work you might have to put it on QMAKE_CXXFLAGS, but try what he says first.

                              1 Reply Last reply
                              0
                              • aha_1980A aha_1980

                                @DiBosco Have you already seen https://stackoverflow.com/questions/22129383/removing-unused-parameters-warning-in-qtcreator ?

                                For your case, it would be: QMAKE_CXXFLAGS_WARN_ON += -Wno-deprecated-copy

                                Regards

                                D Offline
                                D Offline
                                DiBosco
                                wrote last edited by DiBosco
                                #15

                                @aha_1980 said in How to switch off specific warnings in Qt Creator:

                                @DiBosco Have you already seen https://stackoverflow.com/questions/22129383/removing-unused-parameters-warning-in-qtcreator ?

                                For your case, it would be: QMAKE_CXXFLAGS_WARN_ON += -Wno-deprecated-copy

                                Regards

                                Ah, yes I had seen that. The English in the most upticked reply just made me go "What?". Just could not understand what they were saying, but I had tried:

                                QMAKE_CXXFLAGS_WARN_ON += -Wdeprecated-copy

                                Thinking why on earth would putting the warning on make it disappear, but out of desperation I gave it a go. Had I realised it needed -Wno-deprecated-copy, not -Wdeprecated-copy I'd've been fine hours ago.

                                Many thanks for that, now doing just what I want.

                                Also @JonB Thanks for your help too.

                                1 Reply Last reply
                                3

                                • Login

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