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. Qt debugger and pointers to arrays
QtWS25 Last Chance

Qt debugger and pointers to arrays

Scheduled Pinned Locked Moved Qt Creator and other tools
11 Posts 8 Posters 11.7k 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.
  • A Offline
    A Offline
    andre
    wrote on last edited by
    #2

    For a real array, that would be hard, I think. For the Qt container classes you can already do that. Problem would be that an array in an off itself does not have set boundaries. So how would the debugger know how many elements there are? At least, that is as far as I understand the issue.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MarcelBarker
      wrote on last edited by
      #3

      In Visual Studio and some other IDEs, you'd type a comma and the number of elements to watch in the array into the watch window. For example "myArray, 6". The Qt debugger doesn't seem to support this though.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Duck
        wrote on last edited by
        #4

        In Locals and Watchers, context menu of your pointer's entry, select "Watch Expression". This creates a new watched expression below.

        There, double click on the entry in the "Names" column, and add "@10" to display 10 entries.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          Duck
          wrote on last edited by
          #5

          @MarcelBarker: Why does a "Qt Ambassador" respond in such a way?

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MarcelBarker
            wrote on last edited by
            #6

            @Duck I'm not sure what you mean. Andre asked how the debugger would know how many elements there are, and I said how Visual Studio does it. I didn't know about the Qt debugger syntax though, thank you for posting that.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on last edited by
              #7

              [quote author="Duck" date="1305323476"]@MarcelBarker: Why does a "Qt Ambassador" respond in such a way?[/quote]

              What is wrong with Marcel's comment?

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • P Offline
                P Offline
                pitoz
                wrote on last edited by
                #8

                The @10 trick seems to show 10 entries starting from the address of the pointer as opposed to the address of the object that is pointed by the pointer and thus doesn't seem to do what's needed (display the contents of the array that is pointed at by the pointer). The memory editor seems to give one an option to display pointer or object pointed to, but the "Add Expression Evaluator" doesn't. What am I missing?

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andrep
                  wrote on last edited by
                  #9

                  If something starts at the address of the pointer, you need to deference the pointer before.

                  In any case, recent builds of Qt Creator allow you to select from about half a dozen ways to display a pointer in the item's context menu, one of them is as a base of an array of items.

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    pitoz
                    wrote on last edited by
                    #10

                    Hey there, thank you for the reply. You are correct, picking one of the display options seems to do the trick, so thank you for that tip! I'm not quite sure I understand the first half of your response and am still puzzled that pointer@10 would have the behavior that I described previously - let me know if there's an easy way to make that work.

                    thank you!

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      starter
                      wrote on last edited by
                      #11

                      [quote author="Duck" date="1305323195"]In Locals and Watchers, context menu of your pointer's entry, select "Watch Expression". This creates a new watched expression below.

                      There, double click on the entry in the "Names" column, and add "@10" to display 10 entries.
                      [/quote]

                      As Duck say, you must specify the size of array when you inspect it as MyArr@Size for one dimensional array, MyArr@Size2@Size1 for two dimensional array and so on. In there the Size parameter can be a value and the variable from the current scope. Then you can easily collaps and expand your array elements in your whatch list. You can also spesify the Size parameter as SizeN x...x Size2 x Size1, where Size1, Size2,...SizeN are sizes of dimensions of your array. In this case you will see all elements of your array in one column.

                      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