[SOLVED]qDebug and debug release



  • Hi,
    this can be a trivial question, but I've got a doubt about qDebug: reading the documentation it seems to me this is much more a logging facility than a debug facility, and if I get it right, it will continue to output messages even for a release compiled version of the application. Am I right? If so, how is the verbose level configured?



  • The only verbosity level you have is the distinction between qDebug, qWarning and qCritical (and qFatal the special case that terminates the application).

    The first two methods do nothing if during compile time the macros QT_NO_DEBUG_OUTPUT or rather QT_NO_WARNING_OUTPUT are defined. One cannot suppress critical messages, though.

    You can set the macro in your .pro file and if you put into a scope you can make that automagic:

    @
    CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT
    @



  • Thanks, it is clear now.



  • Oh, just as a side not, I forgot to mention: You will need to recompile the complete project with the new DEFINE settings, otherwise the change will not be caught up by every source file and you may end up with partially disabled debug output only.



  • Interesting.
    Isn't qtcreator smart enough to do a clean/rebuild all when the .pro file changes?



  • No. Qt Creator does nothing in that respect. All it does, is call "make". With usual makefiles, something is only recompiled, if one of the dependencies of the file has changed (usually the header and source file and the includes of those, in Qt world additionally the .ui file).

    I know of Visual Studio, that if you change a DEFINE the whole project is rebuilt. But as stated, that's not true for makefile based projects, as in Creator.

    Oh, and even if you use the VS toolchain together with Creator on windows, the build is based on makefiles! Creator calls nmake or jom in that case.



  • [quote author="Volker" date="1317931380"]The only verbosity level you have is the distinction between qDebug, qWarning and qCritical (and qFatal the special case that terminates the application).

    The first two methods do nothing if during compile time the macros QT_NO_DEBUG_OUTPUT or rather QT_NO_WARNING_OUTPUT are defined. One cannot suppress critical messages, though.

    You can set the macro in your .pro file and if you put into a scope you can make that automagic:

    @
    CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT
    @
    [/quote]

    I am finding that qDebug() only operates when you run in debug mode, and it does not matter if you have the above CONFIG statement in your .pro or not.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.