PDA

View Full Version : Draw branches in QHeaderView subclass



Nightfox
22nd May 2012, 13:55
I'm subclassing QHeaderView to enable grouping behavior on a tableview just like MS Excel grouping function. The result should be that the user can show/hide columns of the tableview be clicking on [+] / [-] buttons on the table header.

So I've re-implemented the paintSection method to draw the header and the branch like this;
QHeaderView::style()->drawControl(QStyle::CE_Header, &option, painter )
QHeaderView::style()->drawPrimitive(QStyle::PE_IndicatorBranch, &branchOption, painter );

but only the control is drawn. When I comment out the drawControl, the branch is drawn correctly. It's like Qt only allows me to draw one of them within the stack.

I've been reading through the Qt doc to look for z order or something like that but no luck. Does anyone have similar experience?