Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Qt offer a (guaranteed) debug definition?

Does anyone know an officially supported way to include debug-build only code in Qt? For example:

#ifdef QT_DEBUG // do something #endif 

Basically like Q_ASSERT but for more complex tests.

I can't seem to find any documentation which says that the Qt framework guarantees to define a debug macro. If there isn't, what would be a sensible unofficial way to implement this feature project wide?

like image 556
Samuel Harmer Avatar asked Jan 10 '12 10:01

Samuel Harmer


People also ask

How do you use breakpoints in Qt?

Moving Breakpoints To move a breakpoint: Drag and drop a breakpoint marker to another line in the text editor. In the Breakpoint Preset view or the Breakpoints view, select Edit Selected Breakpoints, and set the line number in the Line number field.


2 Answers

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.

like image 79
laalto Avatar answered Oct 05 '22 13:10

laalto


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.

like image 20
eSKon Avatar answered Oct 05 '22 15:10

eSKon