QImage .natvis for ImageWatch?
-
I can't get ImageWatch to display QImage, does anyone have a working .natvis?
I don't understand why this doesn't work (my image is RGB888 == 13). It does display width, height and the rest correctly in the tooltip, but ImageWatch says "Invalid image".
<?xml version="1.0" encoding="utf-8"?> <AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010"> <UIVisualizer ServiceId="{A452AFEA-3DF6-46BB-9177-C0B08F318025}" Id="1" MenuName="Add to Image Watch"/> <Type Name="QImage"> <UIVisualizer ServiceId="{A452AFEA-3DF6-46BB-9177-C0B08F318025}" Id="1" /> </Type> <Type Name="QImage"> <DisplayString >{d->width}x{d->height}}}</DisplayString> <Expand> <Synthetic Name="[type]" Condition="d->format==13"> <DisplayString>UINT8</DisplayString> </Synthetic> <Synthetic Name="[channels]" Condition="d->format==13"> <DisplayString>RGB</DisplayString> </Synthetic> <Item Name="[width]">d->width</Item> <Item Name="[height]">d->height</Item> <Item Name="[data]">d->data</Item> <Item Name="[stride]" >d->bytes_per_line</Item> <Synthetic Name="[format]"> <DisplayString>{d->format,en}</DisplayString> </Synthetic> </Expand> </Type> </AutoVisualizer>
-
I've tested it with Qt 6.3.1 and VS 2022. It's a different version of the extension than the VS 2019 one. Maybe something changed between them? Can you try VS 2022?
Idk otherwise. Both natvis files, yours and mine, work ok for me. I only got the "invalid" display when natvis was not in the right dir, but you're saying that it's not that so I'm out of ideas. Maybe try another image, e.g. some RGBA png? -
The file looks good. Where is your .natvis located? Is it part of the project?
While Visual Studio debugger can pick up .natvis files included in the project the ImageWatch extension sadly can't :(
The .natvis file needs to be located in%userprofile%\documents\Visual Studio <ver>\Visualizers
to be found by the extension. -
The file looks good. Where is your .natvis located? Is it part of the project?
While Visual Studio debugger can pick up .natvis files included in the project the ImageWatch extension sadly can't :(
The .natvis file needs to be located in%userprofile%\documents\Visual Studio <ver>\Visualizers
to be found by the extension.@Chris-Kawa said in QImage .natvis for ImageWatch?:
The file looks good. Where is your .natvis located? Is it part of the project?
While Visual Studio debugger can pick up .natvis files included in the project the ImageWatch extension sadly can't :(
The .natvis file needs to be located in%userprofile%\documents\Visual Studio <ver>\Visualizers
to be found by the extension.It is located in the right folder. I know that because it's alongside another ImageWatch natvis that I wrote for my own image class, and one works perfectly.
I would love to include it in the project, but sadly it seems there's no way to do it with qmake (I didn't know that wouldn't work anyway). -
There should be ImageWatch.log file in that dir. It logs the types it registered. See if there's any problem listed there. For me it works and the log shows
+ Parsing image.natvis ... + Found type QImage ... + -> Registering QImage
I've tested a bit simpler version and it shows up correctly for me. Can you check if that shows up for you?
<Type Name="QImage"> <Expand> <Synthetic Name="[type]"><DisplayString>UINT8</DisplayString></Synthetic> <Item Name="[channels]">d->depth/8</Item> <Item Name="[width]">d->width</Item> <Item Name="[height]">d->height</Item> <Item Name="[data]">d->data</Item> <Item Name="[stride]">d->bytes_per_line</Item> </Expand> </Type>
-
My version was logged as
Registering QImage
. Yours, however, isn't. Puzzling. I'm using VS 2019, ImageWatch v. 1.0.4, Qt 5.15.2 x64.
P. S. Your version does get registered withId=1
. I have removed all my other ImageWatch natvis definitions, but still no image is displayed, only the text "invalid". So it looks like my original version and your simplified one are functionally identical, in that they both don't work (and at some point I thought maybe ID should be different, but that breaks something so better not touch it). -
I've tested it with Qt 6.3.1 and VS 2022. It's a different version of the extension than the VS 2019 one. Maybe something changed between them? Can you try VS 2022?
Idk otherwise. Both natvis files, yours and mine, work ok for me. I only got the "invalid" display when natvis was not in the right dir, but you're saying that it's not that so I'm out of ideas. Maybe try another image, e.g. some RGBA png? -
It does work in VS 2022! But I can't do this image debugging work in VS2022 because when I try to inspect my own class in ImageWatch (with the exact same natvis file that works perfectly in VS2019) it crashes Visual Studio all the time. But good to know I can at least view QImage in VS2022.
-
It does work in VS 2022! But I can't do this image debugging work in VS2022 because when I try to inspect my own class in ImageWatch (with the exact same natvis file that works perfectly in VS2019) it crashes Visual Studio all the time. But good to know I can at least view QImage in VS2022.
@Violet-Giraffe Hm, that's odd. The IDs and everything seem to be the same for 2019 and 2022. Maybe it's not a Qt issue.
Reading the comments on the MS marketplace for the extension similar thing happened to some other people. Maybe if you contact MS through the comments there or via Visual Studio's Send Feedback they'd be able to help to figure this out? They are pretty responsive in my experience.
-
I never said, nor implied, that it was a Qt issue, I'm just asking for advice from Qt people, because who else would know how to use ImageWatch with Qt classes. Good point, I'll see if they will be interested in figuring it out.