Results 1 to 7 of 7

Thread: Qt debugging - inspecting properties?

  1. #1
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question Qt debugging - inspecting properties?

    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...?
    Software Engineer



  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt debugging - inspecting properties?

    Do you link against a debug build of Qt?

  3. #3
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Qt debugging - inspecting properties?

    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.
    Software Engineer



  4. #4
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Qt debugging - inspecting properties?

    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...
    Software Engineer



  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt debugging - inspecting properties?

    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.

  6. The following user says thank you to wysota for this useful post:

    gfunk (28th August 2006)

  7. #6
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Qt debugging - inspecting properties?

    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
    Last edited by gfunk; 28th August 2006 at 18:47.
    Software Engineer



  8. #7
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt debugging - inspecting properties?

    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:

    Qt Code:
    1. QString = t=<d->data, su> size=<d->size, i>
    To copy to clipboard, switch view to plain text mode 

    Using this example, it should become clear how to extract "text" and other properties from an object.
    Save yourself some pain. Learn C++ before learning Qt.

Similar Threads

  1. Replies: 5
    Last Post: 16th May 2006, 20:38
  2. How to initialize properties to a custom plugin widget?
    By high_flyer in forum Qt Programming
    Replies: 2
    Last Post: 28th February 2006, 16:56
  3. QAxWidget Properties
    By ToddAtWSU in forum Newbie
    Replies: 1
    Last Post: 13th February 2006, 17:45

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.