[SOLVED]qDebug and debug release
-
wrote on 6 Oct 2011, 15:54 last edited by
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? -
wrote on 6 Oct 2011, 20:03 last edited by
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
@ -
wrote on 7 Oct 2011, 06:32 last edited by
Thanks, it is clear now.
-
wrote on 7 Oct 2011, 08:49 last edited by
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.
-
wrote on 7 Oct 2011, 08:57 last edited by
Interesting.
Isn't qtcreator smart enough to do a clean/rebuild all when the .pro file changes? -
wrote on 7 Oct 2011, 09:04 last edited by
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.
-
wrote on 9 Oct 2013, 06:54 last edited by
[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.