Results 1 to 4 of 4

Thread: To create a TreeView ,like QtDesigner's WidgetBox

  1. #1
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default To create a TreeView ,like QtDesigner's WidgetBox

    hi
    i need to create a TreeView which should look same as the QtDesigner's WidgetBox(visible at the left side of the designer) . The first level items should be placed inside a rectangular window with the items text on it.

    i have gone through the source code of QtDesigner and found that the QItemDelegate class has been subclassed and the subclassed object has been set to QTreeWidget(through setItemDelegate).
    i have used the same subclassed delegate file but i am not getting the desired results.
    ie. i get two expand symbols. And only after double clicking the items are expanded.

    Is there a simple way to make a TreeWidget same as the QtDesigner's WidgetBox TreeWidget.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: To create a TreeView ,like QtDesigner's WidgetBox

    Quote Originally Posted by babu198649 View Post
    i have used the same subclassed delegate file but i am not getting the desired results.
    ie. i get two expand symbols.
    So you're using SheetDelegate? Apparently something went wrong... but it's hard to say what. The same approach has worked for me.

    And only after double clicking the items are expanded.
    See WidgetBoxTreeView::handleMousePress().

    Is there a simple way to make a TreeWidget same as the QtDesigner's WidgetBox TreeWidget.
    You're on the right track. Just follow the Designer implementation. Or use QxtTreeWidget
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    babu198649 (29th May 2008)

  4. #3
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default Re: To create a TreeView ,like QtDesigner's WidgetBox

    Thanks for the helpful link.

    See WidgetBoxTreeView::handleMousePress().
    At first i used the widgetbox.h file to get the idea. Then i found newform.h file(which provides the dialog at the start of QtDesigner)which is much simple .

    Any Have ,the link u have given is the best solution

    One curious question ,How much time it took u to understand the SheetDelegate class and implement it .
    Last edited by babu198649; 29th May 2008 at 16:07.

  5. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: To create a TreeView ,like QtDesigner's WidgetBox

    Quote Originally Posted by babu198649 View Post
    One curious question ,How much time it took u to understand the SheetDelegate class and implement it .
    Heh well, the implementation is not that hard find from Qt Designer sources (even if it's something like 140k sloc) once you know what to look for. All you need to find is a QItemDelegate subclass which reimplements paint(). Oh, and I had used QStyle and QStyleOption classes before so the button painting routine was quite obvious...
    J-P Nurmi

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.