PDA

View Full Version : Qt Creator How to watch data of actual type in debugger?



kamre
4th June 2011, 18:26
Very simple example with classes hierarchy:


class Object {
public:
Object(int id_) : id(id_) {}
virtual ~Object() {}

private:
int id;
};

class Point: public Object {
public:
Point(double x_, double y_, int id_)
: Object(id_), x(x_), y(y_) {}

private:
double x, y;
};

class Circle: public Point {
public:
Circle(double x_, double y_, double r_, int id_)
: Point(x_, y_, id_), r(r_) {}

private:
double r;
};

int test(Object *obj)
{
return 0; // <== break point here
}

int main()
{
test(new Circle(1.5, -2.5, 3.0, 15));
return 0;
}


When I set breakpoint in QtCreator and try to watch "obj" in debugger it doesn't show the actual (runtime instead of static) type and corresponding data. This is how it looks like:
http://i55.tinypic.com/33ogrjr.png

And I would like to see something like in MSVC debugger:
http://i52.tinypic.com/24fiucm.pnghttp://i52.tinypic.com/24fiucm.png

How can I configure QtCreator to show the actual runtime data?

Santosh Reddy
5th June 2011, 23:32
You have to create your own debugging helper, and plug it into QtCreator, you can use C++ / Python to implement your own debugging helper for your custom types.

http://doc.qt.nokia.com/qtcreator-2.2/creator-debugging-helpers.html

ktk
23rd June 2011, 17:50
Seems to work as expected in builds made from 'master' branch, but not in 2.2.1.