View Full Version : Qt debugging - inspecting properties?

23rd August 2006, 21:06
When you debug Qt, are you able to inspect the properties of a class? For instance, if you have a QListView object, does your debugger show properties such as the gridSize, viewMode, movement, flow, etc ? Seems VS doesn't show these, or maybe I don't have it set up properly? Just wondering if anyone has this working. I know some of the variables are stored in private classes, but not sure why these can't be read if we have the source code for them... what is this d_ptr...?

24th August 2006, 14:42
Do you link against a debug build of Qt?

24th August 2006, 20:55
Yes, I linked against a debug build. Tried rebuilding the Qt debug libs as well to see if that might make any difference, in case some debug symbols might not have been built, but it didn't do anything.

24th August 2006, 21:03
Apparently, I just didn't inspect deep enough. d_ptr is defined at the QObject level, which happened to be 6 levels deep in my list widget. For whatever reason, I expected the private data to exist side-by-side the specific's class data - VS's debugger hid it, as its variable watch list treeview initially shows parent class members collapsed. Though I also never paid much attention to the data members at QObject level. Anyhow, it's probably easier to just inspect someObject->d_ptr directly.

So all Qt's classes that have private data implement it as a subclass of QObjectPrivate, so that's probably how Qt can keep all their private interfaces clean and consistent. Anyhow, nothing to see here, move along... :o

25th August 2006, 08:29
All property values can be obtained by using a QObject::property() function call, so you don't have to break into the private component looking for them, just call the method from your debugger.

28th August 2006, 19:20
I wish I could do that from VS2005's debugger, but I can't figure out how to do it. I just keep getting the message "CXX0052: Error: member function not present". Does anyone know the correct syntax?

For instance, I tried to set watch var: | and it gave:
ui.action_Preferences->property("text") | CXX0052: Error: member function not present

Chicken Blood Machine
28th August 2006, 21:22
I'm not using Visual Studio any more, so I am unable to test this. But this is how I've known it to work in the past:

If you edit the "autoexp.dat" file (do a find for it on your system). You can tell Visual Studio how to display certain Qt types. Here is an example:

QString = t=<d->data, su> size=<d->size, i>

Using this example, it should become clear how to extract "text" and other properties from an object.