IDE Debug Helpers

From Qt Wiki
Revision as of 16:35, 27 August 2016 by Aetf (talk | contribs) (Add another LLDB data formatter link)
Jump to: navigation, search

Qt Creator

Qt Creator directly supports introspection of all Qt Containers and QObject derived classes for Qt 4 and Qt 5. User defined types can be supported in addition, see the Qt Creator documentation for details.


There is an effort to introspect Qt types using LLDB at

KDevelop ships formatter scripts in its LLDB plugin for Qt types that can be used directly in plain LLDB.

MS visual studio QString & QByteArray expansions

The new layout of QString in Qt 5 is hard to inspect using the debugger. The following code can be added to autoexp.dat (c:files(x86)visual studio 9.0\common7\packages\debugger\autoexp.dat) You should add it to the [Visualizer] section, before the STL/ATL containers.

Qt types


preview ([(unsigned short*)$e.d + 2 + $e.offset,su])
stringview ([(unsigned short*)$e.d + 2 + $e.offset,sub])

} QString{

preview ([$e.d])

} QByteArrayData{

preview ([(unsigned char*)$e.d + 4 + $e.offset,s])
stringview ([(unsigned char*)$e.d + 4 + $e.offset,sb])

} QByteArray{

preview ([$e.d])


Unfortunately, sizeof() cannot be used. That is why there is a constant 2 or 4 for the offset pointer. For an x64 build, the sizes most likely need to be doubled.

MS Visual Studio 2012

There is a new way to visualize native type, see for details.

Ready-made .natvis files are included in the Visual Studio add-in.

So we can visualize QString and some other types using qt5.natvis file (save to file: %USERPROFILE%\Documents\Visual Studio 2012\Visualizers\qt5.natvis) <?xml version="1.0" encoding="utf-8"?> <AutoVisualizer >

<Type Name="QString">

<DisplayString>{(char*)d + d->offset,su}</DisplayString>

<Type Name="QtPrivate::RefCount">


<Type Name="QBasicAtomicInteger<int>">


<Type Name="QTypedArrayData<>">

<DisplayString>{{Count = {size}}}</DisplayString>
<Item Name="[size]">size</Item>
<ValuePointer>(iterator) ((char)this + offset)</ValuePointer>

<Type Name="QByteArray">


<!— More Qt5 types… —>


MS Visual Studio 2013

The ".natvis" files introduced in MSVS2012 received some additional attention in MSVS2013: