IDE Debug Helpers
IDE debug helpers
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.
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 <nowiki>[Visualizer]</nowiki> section, before the STL/ATL containers.
<br />; Qt types<br />QStringData{<br /> preview ([(unsigned short*)$e.d + 2 + $e.offset,su])<br /> stringview ([(unsigned short*)$e.d + 2 + $e.offset,sub])<br />}<br />QString{<br /> preview ([$e.d])<br />}<br />QByteArrayData{<br /> preview ([(unsigned char*)$e.d + 4 + $e.offset,s])<br /> stringview ([(unsigned char*)$e.d + 4 + $e.offset,sb])<br />}<br />QByteArray{<br /> preview ([$e.d])<br />}<br />
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
"http://code.msdn.microsoft.com/Writing-type-visualizers-2eae77a2":http://code.msdn.microsoft.com/Writing-type-visualizers-2eae77a2 for details.
Ready-made .natvis files are included in the "Visual Studio add-in":http://wiki.qt.io/QtVSAddin, and can be grabbed directly from "gitorious":https://qt.gitorious.org/qt-labs/vstools/source/tools/Qt4EEAddin/qt5.natvis.
So we can visualize QString and some other types using .natvis file
(save to file: USERPROFILEDocuments\Visual Studio 2012\Visualizers\Qt5.natvis&#41;
<br />&lt;?xml version="1.0&quot; encoding="utf-8&quot;?&gt;<br /><AutoVisualizer >
<Type Name="QString&quot;><br /> <DisplayString&gt;{(char*)d + d-&gt;offset,su}</DisplayString&gt;<br /> </Type&gt;
<Type Name="QtPrivate::RefCount&quot;><br /> <DisplayString&gt;{atomic}</DisplayString&gt;<br /> </Type&gt;
<Type Name="QBasicAtomicInteger&amp;amp;lt;int&amp;amp;gt;"><br /> <DisplayString&gt;{_q_value}</DisplayString&gt;<br /> </Type&gt;
<Type Name="QTypedArrayData&amp;amp;lt;'''&amp;gt;"><br /> <DisplayString&gt;{{Count = {size}}}</DisplayString&gt;<br /> <Expand&gt;<br /> <Item Name="[size]">size&lt;/Item&gt;<br /> <ArrayItems&gt;<br /> <Size&gt;size&lt;/Size&gt;<br /> <ValuePointer&gt;(iterator) ((char''')this + offset)</ValuePointer&gt;<br /> </ArrayItems&gt;<br /> </Expand&gt;<br /> </Type&gt;
<Type Name="QByteArray&quot;><br /> <DisplayString&gt;{*d}</DisplayString&gt;<br /> </Type&gt;
&lt;!— More Qt5 types… —&gt;
</AutoVisualizer&gt;<br />
MS Visual Studio 2013
The ".natvis" files introduced in MSVS2012 received some additional attention in MSVS2013: