serge
serge

Reputation: 415

QTreeWidget expand sign

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

Upvotes: 6

Views: 9123

Answers (2)

serge
serge

Reputation: 415

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

Upvotes: 8

Georg Schölly
Georg Schölly

Reputation: 126175

QTreeWidgetItems have the property childIndicatorPolicy. The allowed values are:

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

You want the first one.

theItem.setChildIndicatorPolicy(QTreeWidgetItem.ShowIndicator)

Upvotes: 9

Related Questions