How to switch off specific warnings in Qt Creator
- 
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-copyHowever, 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 :) 
- 
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-copyHowever, 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 :) 
- 
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-copyHowever, 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 :) @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_offin your .pro file to disable warnings. This will make sure the compiler is called with all the flags set inQMAKE_CXXFLAGS_WARN_OFF(which should be automatically set by the default mkspecs, so usually no reason to change it).
- 
@DiBosco 
 Did you actually try it though? I read the answer as indicating/suggesting thatCONFIG += warn_offis required to makeQMAKE_CXXFLAGS_WARN_OFFbe taken into account? The OP there seemed to say same as you: settingQMAKE_CXXFLAGS_WARN_OFFalone 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_OFFactually affect things if it does it right from theCONFIGstatement but not in your case?
- 
@DiBosco 
 Did you actually try it though? I read the answer as indicating/suggesting thatCONFIG += warn_offis required to makeQMAKE_CXXFLAGS_WARN_OFFbe taken into account? The OP there seemed to say same as you: settingQMAKE_CXXFLAGS_WARN_OFFalone 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_OFFactually affect things if it does it right from theCONFIGstatement but not in your case?
- 
@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-copyNo warnings at all. If I take out the: CONFIG += warn_offline then all warnings are present. @DiBosco 
 I already suggested: you ought find out why (apparently, according to you and the other poster) that withoutCONFIG += warn_offsettingQMAKE_CXXFLAGS_WARN_OFF -= -Wdeprecated-copyhas no effect. Then maybe you will be able to removeCONFIGand know what you have to do to makeQMAKE_CXXFLAGS_WARN_OFF -= -Wdeprecated-copywork on its own.Not that I know anything about this, but I would guess that QMAKE_CXXFLAGS_WARN_OFFis only used at all if you haveCONFIG += warn_off, i.e. the latter "activates" the former's flags to be used. Without that configurationQMAKE_CXXFLAGS_WARN_OFFis not passed to compiler. If you want-Wdeprecated-copyin other circumstances than with all other warnings turned off I would presume you should use another variable which is always passed to compiler. Something likeQMAKE_CXXFLAGS? Does that satisfy you?
- 
@DiBosco 
 I already suggested: you ought find out why (apparently, according to you and the other poster) that withoutCONFIG += warn_offsettingQMAKE_CXXFLAGS_WARN_OFF -= -Wdeprecated-copyhas no effect. Then maybe you will be able to removeCONFIGand know what you have to do to makeQMAKE_CXXFLAGS_WARN_OFF -= -Wdeprecated-copywork on its own.Not that I know anything about this, but I would guess that QMAKE_CXXFLAGS_WARN_OFFis only used at all if you haveCONFIG += warn_off, i.e. the latter "activates" the former's flags to be used. Without that configurationQMAKE_CXXFLAGS_WARN_OFFis not passed to compiler. If you want-Wdeprecated-copyin other circumstances than with all other warnings turned off I would presume you should use another variable which is always passed to compiler. Something likeQMAKE_CXXFLAGS? Does that satisfy you?
- 
I'm not sure I've made it clear that with CONFIG += warn_offAll 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. @DiBosco said in How to switch off specific warnings in Qt Creator: I'm not sure I've made it clear that with CONFIG += warn_offAll 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. 
- 
I'm not sure I've made it clear that with CONFIG += warn_offAll 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. @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_OFFprobably has no effect and precisely what you should do, which you apparently have not tried.....
- 
@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_OFFprobably has no effect and precisely what you should do, which you apparently have not tried.....I think I'm missing something here because I said a few posts up I tried: CONFIG += warn_off QMAKE_CXXFLAGS_WARN_OFF -= -Wdeprecated-copySo 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. 
- 
@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-copyRegards 
- 
I think I'm missing something here because I said a few posts up I tried: CONFIG += warn_off QMAKE_CXXFLAGS_WARN_OFF -= -Wdeprecated-copySo 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. @DiBosco 
 :)- Forget about CONFIG ..., remove it.
- Forget about QMAKE_CXXFLAGS_WARN_OFF ..., remove it.
- Try this:
 If you want -Wdeprecated-copyin other circumstances than with all other warnings turned off I would presume you should use another variable which is always passed to compiler. Something likeQMAKE_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-copyIf that does not work we (you!) need to understand what is adding -Wdeprecated-copyon the gcc compiler line (I asked you to look at the actual line being generated, does it have that option?) and then presumably something likeTHE_MACRO_WHICH_ADDED_IT -= -Wdeprecated-copyto remove it?P.S. 
 Since @aha_1980 has just chimed in to say there is aQMAKE_CXXFLAGS_WARN_ONand a-Wno-deprecated-copywhich can be added you should try that. If by any chance that does not work you might have to put it onQMAKE_CXXFLAGS, but try what he says first.
- Forget about 
- 
@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-copyRegards @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-copyRegards 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. 
 

