tags:

views:

158

answers:

2

Hi everyone,

How to make expandable sign in QTreeWidget always visible even when item doest have any subitems? And how to draw something else instead of default sign?

Thanks in advance, Serge

+2  A: 

QTreeWidgetItems have the property childIndicatorPolicy. The allowed values are:

  • QTreeWidgetItem::ShowIndicator
  • QTreeWidgetItem::DontShowIndicator
  • QTreeWidgetItem::DontShowIndicatorWhenChildless

You want the first one.

theItem.setChildIndicatorPolicy(QTreeWidgetItem.ShowIndicator)
Georg
Thanks a lot, it helped, and for the second part of my question - i found the solution myself
serge
+4  A: 

Answering on my second part of question for others.

I looked for drawing functions in QTreeView and found following:

void QTreeView::drawBranches ( QPainter * painter, const QRect & rect, const QModelIndex & index ) 

With this function you can draw whatever you want at the left side of each item.

And another good choice to hanlde this - use Style Sheets for QTreeView:

http://qt.nokia.com/doc/4.6/stylesheet-examples.html#customizing-qtreeview

serge