View Full Version : Hide the branches in a QTreeWidget
SkripT
7th March 2006, 13:31
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.
You mean expanding/collapsing?
void QTreeWidget::setItemExpanded (http://doc.trolltech.com/4.1/qtreewidget.html#setItemExpanded) ( const QTreeWidgetItem * item, bool expand)
SkripT
7th March 2006, 13:42
You mean expanding/collapsing?
No, I mean not to draw the branches joining each item in the tree view with its parent
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.
SkripT
7th March 2006, 16:24
Many thanks jpn
SkripT
8th March 2006, 11:12
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?
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).
SkripT
8th March 2006, 16:14
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)?
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..
SkripT
8th March 2006, 19:16
Looks cool jpn, it's exactly what I need. Thanks a lot one more time.
josh
3rd April 2007, 22:09
This helped us (http://www.soph-ware.com/) too, thanks.
vBulletin® v3.7.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.