Image 01
profile-image

Sethien

Tom  Conijn
HierarchicalHeaderView

Qt Widgets 50 comments

Score 70.0%
Feb 10 2011
Hello,

I'm not 100% sure that this is what you want, but you should be able to add extra items in the header.(I used the example 2 project, and modified it a bit, so it works with QT 5.3.2) The example 2 project only uses the horizontal header and i added 8 items.

Hope it helps you with what you want, and otherwise let me know, maybe i can help you.

Project files:
https://www.dropbox.com/s/xqkmf6oa5r6lj8l/hv_example%28modified%29%20use%20example%202.zip?dl=0

Picture of the result:
http://imgur.com/TD0RSWP - Dec 02 2014
Ok i don't know what happend but it seems that my browser kept posting the same message, sorry for the extra posts - Aug 27 2014
Ok I fixed the height of the header items by reimplementing the: virtual QSize sizeHint() const;

And i enabled the sort icon by adding:
if (isSortIndicatorShown() && sortIndicatorSection() == logicalInd)
opt.sortIndicator = (sortIndicatorOrder() == Qt::AscendingOrder) ? QStyleOptionHeader::SortDown : QStyleOptionHeader::SortUp;

to the styleOptionForCell funtion.

But when clicking on the horizontal header item that spans 2 columns the sortIndicator will only show for the whole button when i click on the right part. When i click on the left part the sortIndicator is shown half. Does anyone have a solution to make this working on only half the column item or both on the whole item?

see the pictures for more information:
http://imgur.com/FWRSUx7,CLKGpao,oPTpjVk - Aug 27 2014
Ok I fixed the height of the header items by reimplementing the: virtual QSize sizeHint() const;

And i enabled the sort icon by adding:
if (isSortIndicatorShown() && sortIndicatorSection() == logicalInd)
opt.sortIndicator = (sortIndicatorOrder() == Qt::AscendingOrder) ? QStyleOptionHeader::SortDown : QStyleOptionHeader::SortUp;

to the styleOptionForCell funtion.

But when clicking on the horizontal header item that spans 2 columns the sortIndicator will only show for the whole button when i click on the right part. When i click on the left part the sortIndicator is shown half. Does anyone have a solution to make this working on only half the column item or both on the whole item?

see the pictures for more information:
http://imgur.com/FWRSUx7,CLKGpao,oPTpjVk - Aug 27 2014
Ok I fixed the height of the header items by reimplementing the: virtual QSize sizeHint() const;

And i enabled the sort icon by adding:
if (isSortIndicatorShown() && sortIndicatorSection() == logicalInd)
opt.sortIndicator = (sortIndicatorOrder() == Qt::AscendingOrder) ? QStyleOptionHeader::SortDown : QStyleOptionHeader::SortUp;

to the styleOptionForCell funtion.

But when clicking on the horizontal header item that spans 2 columns the sortIndicator will only show for the whole button when i click on the right part. When i click on the left part the sortIndicator is shown half. Does anyone have a solution to make this working on only half the column item or both on the whole item?

see the pictures for more information:
http://imgur.com/FWRSUx7,CLKGpao,oPTpjVk - Aug 27 2014
Ok I fixed the height of the header items by reimplementing the: virtual QSize sizeHint() const;

And i enabled the sort icon by adding:
if (isSortIndicatorShown() && sortIndicatorSection() == logicalInd)
opt.sortIndicator = (sortIndicatorOrder() == Qt::AscendingOrder) ? QStyleOptionHeader::SortDown : QStyleOptionHeader::SortUp;

to the styleOptionForCell funtion.

But when clicking on the horizontal header item that spans 2 columns the sortIndicator will only show for the whole button when i click on the right part. When i click on the left part the sortIndicator is shown half. Does anyone have a solution to make this working on only half the column item or both on the whole item?

see the pictures for more information:
http://imgur.com/FWRSUx7,CLKGpao,oPTpjVk - Aug 27 2014
Ok I fixed the height of the header items by reimplementing the: virtual QSize sizeHint() const;

And i enabled the sort icon by adding:
if (isSortIndicatorShown() && sortIndicatorSection() == logicalInd)
opt.sortIndicator = (sortIndicatorOrder() == Qt::AscendingOrder) ? QStyleOptionHeader::SortDown : QStyleOptionHeader::SortUp;

to the styleOptionForCell funtion.

But when clicking on the horizontal header item that spans 2 columns the sortIndicator will only show for the whole button when i click on the right part. When i click on the left part the sortIndicator is shown half. Does anyone have a solution to make this working on only half the column item or both on the whole item?

see the pictures for more information:
http://imgur.com/FWRSUx7,CLKGpao,oPTpjVk - Aug 27 2014
Picture to make it more clear: http://imgur.com/t7TI0JP

With my solution the header is twice as big than needed. - Aug 27 2014
Hello,

i'm using this application on qt 5.3.1 and i'm wondering if it's possible to hide the subcolumns of the horizontal header, but still make it possible for the root horizontal header element to span over multiple columns.

For now I sort of got a solution, I change the height of an item depending on the name/text. So if it's a subitem i set the height to 0, but the header will use the same height as when it contains the sub header column as well. So when hiding the subcolumns i want the height of the header to change as well.

So is there a better way to hide the subcolumns but keep the root column header spanning and change the height of the horizontal header to the height it is when only root items are used. - Aug 27 2014