Results 1 to 14 of 14

Thread: QObjectBrowser

  1. #1
    Join Date
    Feb 2007
    Location
    Philadelphia, USA
    Posts
    255
    Thanks
    43
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QObjectBrowser

    I put together a little Qt4 utility that conveniently allows inspection of a QObject's properties, signals, and slots during program execution. It even keeps a tally on how many times the various signals have been triggered. I guess its the idea of QtObjectInspector, but very lightweight...

    Perhaps it's been done before, but I think it could be very nice for debugging.... and quite easy to use.

    Usage: include the attached files in your project. Then just go:

    Qt Code:
    1. QObjectBrowser *browser=new QObjectBrowser(pointer_to_my_widget);
    2. browser.showNormal();
    To copy to clipboard, switch view to plain text mode 

    Anyone's welcome to fancy it up... but don't everybody start modifying the code at once! Tell me if you plan to add a feature or improve the look.

    Enjoy!
    JM
    Attached Files Attached Files

  2. The following user says thank you to magland for this useful post:

    Walter (28th July 2007)

  3. #2
    Join Date
    Feb 2007
    Location
    Philadelphia, USA
    Posts
    255
    Thanks
    43
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QObjectBrowser

    I've added some features (attachment).

    You can now see the child and parent objects for the given QObject, and double click to navigate to those widgets/objects. This way you only need to set up QObjectBrowser for your top level widget and then navigate down to debug your entire application...

    Let me know if anyone finds this useful. I'll keep developing if I see there are interested users...
    Attached Files Attached Files

  4. #3
    Join Date
    Jan 2006
    Posts
    24
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QObjectBrowser

    Hi,

    I just did:

    - Moved ui file from QDialog to QWidget
    - Improved layout
    - Sets "void" if the method type name is empty


    I attached the patch and the project
    Attached Files Attached Files

  5. The following user says thank you to krawek for this useful post:

    magland (15th June 2007)

  6. #4
    Join Date
    Feb 2007
    Location
    Philadelphia, USA
    Posts
    255
    Thanks
    43
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QObjectBrowser

    Thanks very much... looks great. Future contributions should take it up from krawek's version.

    I think this could become quite a useful tool.... I envision being able to change the values of properties during run time - (for debugging purposes). Also helpful to see the structure of an application.

    JM

  7. #5
    Join Date
    Feb 2007
    Location
    Philadelphia, USA
    Posts
    255
    Thanks
    43
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QObjectBrowser

    Okay, I've added a tree control, so you can see a hierarchical tree of all the widgets in your application. Click on a widget to see all the properties, signals, slots, etc.

    This is convenient, because you don't need to attach to an initial QObject any more. Simply use the following anywhere in your application:

    Qt Code:
    1. QObjectBrowser *browser=new QObjectBrowser;
    2. browser->showNormal();
    To copy to clipboard, switch view to plain text mode 

    I've attached the project file.

    Feedback?

    Attached Files Attached Files
    Last edited by magland; 18th June 2007 at 13:53. Reason: Updating attached file

  8. #6
    Join Date
    Feb 2007
    Location
    Philadelphia, USA
    Posts
    255
    Thanks
    43
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QObjectBrowser

    Twice the functionality!
    Please download and give feedback ...

    New features:
    * Automatically updates application's widget/object hierarchy every 3 seconds -- safely deletes old widgets in real time as they are closed/deleted

    * Click the "Browse Focus Widget" to see the properties/signals/slots for the widget with current input focus --- great for reminding you which widgets are which - or for discovering the widget structure for someone else's source code!

    * Right click on a widget/object in the tree to get a popup menu -- allows to hide/show/focus any widget at any time --- have you ever wondered what the "Qt internal tablet widget" looks like - now you can find out.

    * As before, you get a real time tally of triggered signals...

    Attached Files Attached Files

  9. #7
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QObjectBrowser

    Just wondering how you guess the "base class"... AFAIK QTreeWidget can't be a base class because it inherits QTreeView, which itself inherits QAbstractItemView, which itself... Can you print informations about interfaces that would be implemented by an object? Is it possible to modify the behavior of the app by adding connections on runtime? Is it possible to force a signal to be triggered or a slot to be executed? I think those could prove useful when debugging an app...
    Sounds quite interesting anyway... Keep up the good work Maybe you'll someday find a trick to hook QObjectBrowser to a running Qt app without being forced to recompile it... It would just be SOOOOOOOOO neat
    Current Qt projects : QCodeEdit, RotiDeCode

  10. #8
    Join Date
    Feb 2007
    Location
    Philadelphia, USA
    Posts
    255
    Thanks
    43
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QObjectBrowser

    Thanks for the encouragement fmc.

    Quote Originally Posted by fullmetalcoder View Post
    Just wondering how you guess the "base class"...
    I use QMetaObject::superClass(). Maybe base class isn't the right word?

    Quote Originally Posted by fullmetalcoder View Post
    Can you print informations about interfaces that would be implemented by an object?
    I can if that info is in QMetaObject... haven't figured that out yet

    Quote Originally Posted by fullmetalcoder View Post
    Is it possible to modify the behavior of the app by adding connections on runtime? Is it possible to force a signal to be triggered or a slot to be executed? I think those could prove useful when debugging an app...
    Yes I'm planning to put that in at some point.

    Quote Originally Posted by fullmetalcoder View Post
    Sounds quite interesting anyway... Keep up the good work Maybe you'll someday find a trick to hook QObjectBrowser to a running Qt app without being forced to recompile it... It would just be SOOOOOOOOO neat
    Thanks... yes if anyone has an idea to hook up to an external application....

  11. #9
    Join Date
    Jan 2007
    Location
    Rome
    Posts
    30
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question Re: QObjectBrowser

    Hi,
    I've just download the last attachment (21 June 2007).
    I try to compile it using Visual Studio C++.NET.
    Using the Qt Visual studio integration I generate a solution starting from the .pro file.
    In this solution I found correctly the example project and the objectbrowser project.
    I compile the objectbrowser project and a .dll file has generated inside the bin folder.
    The .lib file (that must be used by the example project) is not generated.
    So when I try to build the example I receive a link error:

    fatal error LNK1181: cannot open input file 'objectbrowser.lib'

    I don't understand why, but it seems that the integration has create a solution with some wrong settings.

    I would like to use your utility to monitoring my applications But without the .lib file I cannot link against the .dll file.

    Any suggestions ?

    Best,

    Angelo

  12. #10
    Join Date
    Feb 2007
    Location
    Philadelphia, USA
    Posts
    255
    Thanks
    43
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QObjectBrowser

    You could try to go to the src\src.pro and replace CONFIG = dll with CONFIG = staticlib... then reopen your project...

  13. #11
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QObjectBrowser

    Quote Originally Posted by Angelo Moriconi View Post
    Hi,
    I've just download the last attachment (21 June 2007).
    I try to compile it using Visual Studio C++.NET.
    Using the Qt Visual studio integration I generate a solution starting from the .pro file.
    In this solution I found correctly the example project and the objectbrowser project.
    I compile the objectbrowser project and a .dll file has generated inside the bin folder.
    The .lib file (that must be used by the example project) is not generated.
    So when I try to build the example I receive a link error:

    fatal error LNK1181: cannot open input file 'objectbrowser.lib'

    I don't understand why, but it seems that the integration has create a solution with some wrong settings.

    I would like to use your utility to monitoring my applications But without the .lib file I cannot link against the .dll file.

    Any suggestions ?

    Best,

    Angelo
    On Windows, you have to explicitly export the classes using Q_DECL_EXPORT.
    See this thread( the last posts ).
    http://www.qtcentre.org/forum/f-newb...age2-7829.html

    regards

  14. #12
    Join Date
    Feb 2006
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QObjectBrowser

    Hi, I just went through my version of this and made some small updates. I was going to upload it back to this page, but while it says I have attach permissions I can't figure out how to attach right now.
    Here is a temporary link until I figure out how to upload it to this site.

    http://lazarus.homelinux.net/objectbrowser.tar.gz

    *** Modified by Alan Ezust in July 2010, April 2011
    Requires Qt 4.6 due to use of QScopedPointer.
    Builds on windows as a library exporting symbols.
    Changes to naming conventions.
    Added toggle-view action: QObjectBrowserAction
    Made ObjectBrowser an embeddable widget instead of a main window.
    Use alternate properties for objectname in tree view.

  15. #13
    Join Date
    Feb 2007
    Location
    Philadelphia, USA
    Posts
    255
    Thanks
    43
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QObjectBrowser

    Alan, that's great -- thanks for the link!

  16. #14
    Join Date
    Feb 2006
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QObjectBrowser

    The link above no longer is good, and I figured out how to attach files so here it is:
    Attached Files Attached Files

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.