Unfortunately QObject has nothing like a QString m_objectName member visible in the debugger as one might expect. Instead, all of the implementation data is hidden behind opaque pointers. Is there any way to view the objectName at runtime from within the Visual Studio debugger?
Background:
When debugging a Qt Application, there may be many instances of a particular QObject and it can be difficult to know which one triggered a crash, since that information may not available in the call stack. However in the case where they have all been given unique objectNames, that could in theory allow one to quickly pinpoint the problematic code area.
More Details:
- I'm using Qt 5.9.3 and Visual Studio 2019
- I've already installed
qt5.natvisfor Visual Studio (and it doesn't do this for you) - I'm asking for, at minimum, a working watch-expression which can be pasted into the debugger for any local
QObjectderived variable with an objectName, in order to display its objectName. - The ideal answer will also include the updated
qt5.natviswhich prominently exposes objectName for any localQObjectderived variables.