Results 1 to 3 of 3

Thread: QTreeWidget & QStyle::PE_IndicatorBranch

  1. #1

    Default QTreeWidget & QStyle::PE_IndicatorBranch

    Hi,
    as far i saw the default behaviour for QTreeWidget when adding a topLevelItem is not showing the branch indicator (the item to expand or collapse the subtree) if this item has no child.
    Now i want to show an indicator even if the topLevelItem has no child.
    I've played around subclassing QStyle and implementing drawElement to handle the case of a PE_IndicatorBranch. The problem is that i'm not able to decide in drawElement if the item processed is a topLevelItem or a child item. I've tryed to obtain this information looking at state() and QStyle::StateFlag but i'm not able to obtain the desidered behaviour.
    Can anyone help me showing me some actual code ? or a way to solve this problem ?

    Thanks in advance.
    Giorgio

  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: QTreeWidget & QStyle::PE_IndicatorBranch

    The QStyleOption parameter indeed delivers all the information including, amongst the others, whether the index has children and whether it's expanded or collapsed. However, there is no way in a style to know if it's a top level index in question.

    You could try to override QTreeView::drawBranches(). That's where the QStyle::drawPrimitive(PE_IndicatorBranch) is called from. You could then try to pass a custom combination of state flags in case it is a top level item.
    J-P Nurmi

  3. #3

    Default Re: QTreeWidget & QStyle::PE_IndicatorBranch

    Thank you for reply, i solved the problem overriding , as you suggested, drawBranch using the QModelIndex parameter and model() to get more info from the tree.
    G.

Similar Threads

  1. resizing a QTreeWidget
    By drhex in forum Qt Programming
    Replies: 6
    Last Post: 27th October 2006, 22:32
  2. Replies: 1
    Last Post: 21st September 2006, 10:37
  3. QTreeWidget & QListWidget different selection
    By munna in forum Qt Programming
    Replies: 9
    Last Post: 21st July 2006, 06:50
  4. How to capture resizing of QTreeWidget columns?
    By simk in forum Qt Programming
    Replies: 2
    Last Post: 27th April 2006, 06:10
  5. few questions related to QTreeWidget
    By prakash in forum Qt Programming
    Replies: 9
    Last Post: 10th March 2006, 07: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.