I am using Qt on Ubuntu. When I debug I only see the very first value of the array in Locals and Watchers. How can I view all the array contents?
struct node
{
int *keys;
void **pointers;
int num_keys;
struct node *parent;
int is_leaf;
struct node *nextLevelNode;
};
It shows only the first key value in the debugging window.
In Expression evaluator, Try
(int[10])(*myArray)
instead of(int[10])myArray
Or,
*myArray@10
instead ofmyArray@10
In Qt for mac what worked for me was:
I presume you're referring to the pointer keys, declared with
int *keys;
The debugger doesn't know that this is an array: all it knows is that this is a pointer to an
int
. So it can't know how many values you want it to display.What I've found, using the Qt Creator 2.1.0 debugger on Ubuntu, is that the following code allows me to see all 5 values:
Whereas with this code, the debugger only shows the first value, exactly as you describe.
Aside: of course, the above code would be followed by this, to avoid leaking memory:
Later: This Qt Developer Network Forum Post says that you can tell the debugger to display a pointer as an array:
This sounds like it should get you going.
Two dimensional arrays sometimes cannot be displayed that way. There is a work-around. First, declare a two-dimensional array as a one-dimensional array like this:
Then add
(int[3][4]) *array2D
to the expression evaluator. Unfortunately you have to index the array your self, but you can write a special-purpose inline function or use another encapsulation method to make it slightly cleaner.Just right-click on your variable, and choose
Change Value Display Format
and checkArray of 100 items
.