0

It seems that visualizing Qt5.6 QStrings in the Visual Studio 2015 debugger does not work with the standard way of QString visualization (adding a natvis to Visual Studio 2015\Visualizers) as one did in Visual Studio 2013 and before. Is this correct? Has anyone managed to add QString visualization in VS 2015?

John Neuhaus
  • 1,784
  • 20
  • 32
user3640262
  • 57
  • 2
  • 7

3 Answers3

3

I had been doing this successfully in VS 2015 with Qt 5.6 for a while, although either update 3 or an addition I made started screwing things up. This is the definition I used:

<Type Name="QString">
    <DisplayString IncludeView="nq">{((reinterpret_cast&lt;unsigned short*&gt;(d)) + d->offset / 2),sub}</DisplayString>
    <DisplayString ExcludeView="nq">"{((reinterpret_cast&lt;unsigned short*&gt;(d)) + d->offset / 2),sub}"</DisplayString>
    <StringView>((reinterpret_cast&lt;unsigned short*&gt;(d)) + d->offset / 2),sub</StringView>
    <Expand HideRawView="true">
        <Item ExcludeView="simple" Name="[size]">d-&gt;size</Item>
        <Item ExcludeView="simple" Name="[referenced]">d-&gt;ref.atomic._q_value</Item>
        <ArrayItems ExcludeView="simple">
            <Size>d-&gt;size</Size>
            <ValuePointer>((reinterpret_cast&lt;unsigned short*&gt;(d)) + d->offset / 2),c</ValuePointer>
        </ArrayItems>
    </Expand>
</Type>

If you have the Qt5.natvis file that comes with the now deprecated VS Addin, I added it to my solution so I could modify it. There were a number of things that didn't work quite right, and I've been adding plenty more types as I go.

Note: I added a view to display the string without quotes, and added the ability to use view(simple) elsewhere to suppress the children, but I think this is otherwise unmodified.

If you're still having trouble, you can turn on warning or verbose logging for Natvis:

Options > Debugging > Output Window

John Neuhaus
  • 1,784
  • 20
  • 32
3

You can try Qt Visual Studio Tools

Cong Ma
  • 1,241
  • 1
  • 11
  • 20
2

The easiest automatic way to add debugging compatibility to Visual Studio for Qt is installing the Qt Visual Studio Tools and setting the Debugger Type to "Mixed" in project properties -> Configuration Properties -> Debugging.

Tested for Qt 5.9.1 and Visual Studio 2015

RoQuOTriX
  • 2,871
  • 14
  • 25