Results 1 to 20 of 20

Thread: Hide the branches in a QTreeWidget

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Hide the branches in a QTreeWidget

    Hi all, as the post says I want to hide the branches in a QTreeWidget. I attach an image showing the result that I want. I think that the solution could be calling QTreeView::drawBranches but I don't know how to make it. Anybody knows it?

    Thanks.
    Attached Images Attached Images

  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: Hide the branches in a QTreeWidget

    You mean expanding/collapsing?
    void QTreeWidget::setItemExpanded ( const QTreeWidgetItem * item, bool expand)

  3. #3
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Hide the branches in a QTreeWidget

    Quote Originally Posted by jpn
    You mean expanding/collapsing?
    No, I mean not to draw the branches joining each item in the tree view with its parent

  4. #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: Hide the branches in a QTreeWidget

    Quote Originally Posted by SkripT
    No, I mean not to draw the branches joining each item in the tree view with its parent
    Ah of course, sorry for being so thoughtless.

    Yes, reimplementing drawBranches() and leave it empty.
    Last edited by jpn; 7th March 2006 at 13:30.

  5. #5
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Hide the branches in a QTreeWidget

    Many thanks jpn

  6. #6
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Hide the branches in a QTreeWidget

    Hi again, I've reimplemented drawBranches leaving it empty and the branches are not drawn (as I wanted), the problem is that the icons to expand/colapse the tree items aren't neither painted but in the example that I have attached are painted. Anybody knows how to force to paint them withoyt having to draw the branches?
    Last edited by SkripT; 8th March 2006 at 10:14.

  7. #7
    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: Hide the branches in a QTreeWidget

    In that case you most probably need to implement your own style which can draw that kind of primitive elements the way you want (QStyle::PE_IndicatorBranch).

  8. #8
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Hide the branches in a QTreeWidget

    Ok thanks jpn, but, and sorry for my ingnorance, how could I call to paint the QStyle::PE_IndicatorBranch directly (if it's possible to do it)?

  9. #9
    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: Hide the branches in a QTreeWidget

    Mom, look what I did!! Heh, this was kinda interesting so I gave it a shot. Never played too much with styles...

    Create an instance of the attached style and set it for your treewidget (QWidget::setStyle(QStyle*)).
    And remember to remove the empty drawBranches() from your treewidget..
    Attached Images Attached Images
    Attached Files Attached Files

  10. The following 3 users say thank you to jpn for this useful post:

    gfunk (30th May 2006), josh (3rd April 2007), WinchellChung (6th June 2007)

  11. #10
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Hide the branches in a QTreeWidget

    Looks cool jpn, it's exactly what I need. Thanks a lot one more time.
    Last edited by SkripT; 8th March 2006 at 18:19.

  12. #11
    Join Date
    Apr 2007
    Posts
    1
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Hide the branches in a QTreeWidget

    This helped us too, thanks.

Similar Threads

  1. resizing a QTreeWidget
    By drhex in forum Qt Programming
    Replies: 6
    Last Post: 27th October 2006, 22:32

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
  •  
Qt is a trademark of The Qt Company.