Does Qt offer a (guaranteed) debug definition?

六月ゝ 毕业季﹏ 提交于 2019-12-02 19:56:41

Qt defines QT_NO_DEBUG for release builds. Otherwise QT_DEBUG is defined.

Of course you are free to specify any DEFINES in your .pro files and scope them for either debug or release.

eSKon

An alternative is to write in your project file something like:

debug {
  DEFINES += MYPREFIX_DEBUG
}
release {
  DEFINES += MYPREFIX_RELEASE
}

Then you will not depend on the Qt internal definition.

For check debug mode:

#ifdef QT_DEBUG
    //Some codes
#endif

For check release mode:

#ifndef QT_DEBUG    //<== Please note... if not defined
    //Some codes
#endif
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!