Debugging asserts in Qt Creator


Question

When I hit a normal assert statement while debugging with Visual Studio I get the option to break into the debugger so I can see the entire stack trace and the local variables, not just the assert message.

Is it possible to do this with Qt Creator+mingw32 and Q_ASSERT/Q_ASSERT_X?

1
20
1/21/2010 9:08:51 AM

Accepted Answer

You can install a handler for the messages/warnings that Qt emits, and do your own processing of them. See the documentation for qInstallMsgHandler and the example they give there. It should be easy to insert a break in a custom message handler (or indeed, just assert on your own at that point). The one small drawback is that you'll be a bit further on down the stack than where the error actually occurred, but it is a simple matter to just step up the stack until you are at the proper frame.

8
9/16/2014 6:54:18 PM

It's possible. Somehow the feature stopped working for me, but basically what you want is to stop on qFatal(). To ensure this happens, in qt Creator go to Tools -> Options -> Debugger -> GDB and select "Stop when a qFatal is issued"


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon