How to determine the header row height in QTreeView
Hi there,
in a class derived from QTreeView I need to find out he height of the header row in order to correct the coordinates reported in a hover event and find the model index corresponding to the mouse position. It turns out, that the position reported is relative to the top left corner of the widget, but I need the coordinate relative to the top left corner of the inner tree view itself. Thus, I need to find out the height of the header row.
However, calling the parent's class function
Code:
QTreeView::headerData(0, Qt
::Horizontal, Qt
::SizeHintRole)
only returns a QSize(-1,-1) which probably corresponds to a QVariant().
So, how can I find out the height of the header row?
Re: How to determine the header row height in QTreeView
Either ask for its height() or better yet ask the view for the index underneath the pointer using QAbstractItemView::indexAt.
Re: How to determine the header row height in QTreeView
Quote:
Originally Posted by
wysota
Well, I already use QAbstractItemView::indexAt but it gives me the model index one or two below the one my mouse hovers above (because the position that indexAt requests must be relative to the top left corner of the white tree view area).
However, I finally managed to get it using treeView->header()->sizeHint(), so I guess this is the way to go about it.
Re: How to determine the header row height in QTreeView
Probably you should have done this: