PDA

View Full Version : Disable qDebug output



the_bis
11th October 2006, 11:21
I have put into my code a lot of strings like this:



qDebug ( "My value is: %s\n", Value.ascii() );


I'd like to view this messages only if I compile my application with debug enabled but I see it with any project configuration.
My ".pro" file contains now:



CONFIG += qt warn_off release


How con I get rid of qDebug messages in my compiled QT application?

Thanks,
the_bis

e8johan
11th October 2006, 11:28
Define QT_NO_DEBUG_OUTPUT during compilation and it will go away.

the_bis
11th October 2006, 14:28
Define QT_NO_DEBUG_OUTPUT during compilation and it will go away.

No luck, I still see the qDebug strings in my shell.

Now my "project.pro" file have:



CONFIG += qt warn_off release
DEFINES += QT_NO_DEBUG_OUTPUT
DEFINES += QT_NO_DEBUG


I've already re-run "qmake project.pro" command but I still have the problem...

Any othet help?

Thanks,
the_bis

jacek
14th October 2006, 20:13
Any othet help?
We have already discussed this (see this thread (http://www.qtcentre.org/forum/f-qt-programming-2/t-qdebug-3830.html)) and it seems that you just can't disable qDebug() output in Qt3.

mikro
30th November 2006, 15:05
i'd like to reuse this thread as i have a connected problem, but in Qt 4.2.0
my .pro starts like this:

TEMPLATE = app
QT += sql gui core qt3support
DEFINES += QT_NO_DEBUG_OUTPUT QT_NO_WARNING_OUTPUT
CONFIG += warn_off release qt app_bundle


in my main.cpp i have:

#ifndef QT_NO_DEBUG_OUTPUT
DebugWindow* deb = DebugWindow::self();
qInstallMsgHandler(debugWinMsgHandler);
#endif

then i deleted everything in my build-directory and tried to rebuild my app (which had been compiling fine as a debugversion) and got building errors which lead me to qglobal.h. there i found this lines:


/*
Forward declarations only.

In order to use the qDebug() stream, you must #include<QDebug>
*/
class QDebug;
class QNoDebug;
#ifndef QT_NO_DEBUG_STREAM
Q_CORE_EXPORT_INLINE QDebug qDebug();
Q_CORE_EXPORT_INLINE QDebug qWarning();
Q_CORE_EXPORT_INLINE QDebug qCritical();
#else
inline QNoDebug qDebug();
#endif

i did change my DEFINES to

DEFINES += QT_NO_DEBUG_OUTPUT QT_NO_WARNING_OUTPUT QT_NO_DEBUG_STREAM

but still i get

C:/Qt/4.2.0/include/QtCore/../../src/corelib/global/qglobal.h:1246: error: expected unqualified-id before "if"
C:/Qt/4.2.0/include/QtCore/../../src/corelib/global/qglobal.h:1246: error: expected `,' or `;' before "if"
C:/Qt/4.2.0/include/QtCore/../../src/corelib/global/qglobal.h:1246: error: expected unqualified-id before "else"
C:/Qt/4.2.0/include/QtCore/../../src/corelib/global/qglobal.h:1246: error: expected `,' or `;' before "else"

line 1246 is the

inline QNoDebug qDebug();
in the quote above. So what is the problem? the way i understand it they forward-declare classes QDebug and QNoDebug, and as i defined QT_NO_DEBUG_STREAM QNoDebug should be used whereve i call qDebug. Sounds fine to me ;)

wysota
30th November 2006, 15:22
What errors did you get in the first place?

mikro
30th November 2006, 15:43
ahem. now that you ask ... i tried again: i get the same errors. so the QT_NO_DEBUG_STREAM seems to make no difference - it seems to be set automatically if the QT_NO_DEBUG_OUTPUT QT_NO_WARNING_OUTPUT are set.
Nevertheless i cannot compile

mikro
30th November 2006, 21:14
well seems that this time it is not my fault:
http://www.trolltech.com/developer/task-tracker/index_html?method=entry&id=133726