Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QImage .natvis for ImageWatch?
QtWS25 Last Chance

QImage .natvis for ImageWatch?

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
9 Posts 2 Posters 979 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Violet Giraffe
    wrote on last edited by
    #1

    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>
    
    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #6

      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?

      1 Reply Last reply
      1
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by
        #2

        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.

        V 1 Reply Last reply
        0
        • Chris KawaC Chris Kawa

          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.

          V Offline
          V Offline
          Violet Giraffe
          wrote on last edited by Violet Giraffe
          #3

          @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).

          1 Reply Last reply
          0
          • Chris KawaC Offline
            Chris KawaC Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on last edited by Chris Kawa
            #4

            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>
            
            1 Reply Last reply
            0
            • V Offline
              V Offline
              Violet Giraffe
              wrote on last edited by Violet Giraffe
              #5

              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 with Id=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).

              1 Reply Last reply
              0
              • Chris KawaC Offline
                Chris KawaC Offline
                Chris Kawa
                Lifetime Qt Champion
                wrote on last edited by
                #6

                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?

                1 Reply Last reply
                1
                • V Offline
                  V Offline
                  Violet Giraffe
                  wrote on last edited by
                  #7

                  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.

                  Chris KawaC 1 Reply Last reply
                  0
                  • V Violet Giraffe

                    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.

                    Chris KawaC Offline
                    Chris KawaC Offline
                    Chris Kawa
                    Lifetime Qt Champion
                    wrote on last edited by
                    #8

                    @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.

                    1 Reply Last reply
                    2
                    • V Offline
                      V Offline
                      Violet Giraffe
                      wrote on last edited by Violet Giraffe
                      #9

                      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.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved