Getting QModelIndex from QHeaderView
-
Simple problem: I reimplemented QHeaderView and am spawning a menu when a section is right-clicked. I'd like part of that menu to have the text which is in the header. I need to get that from either the QAbstractTableModel or QSortFilterProxyModel. I've tried indexAt() in both the QHeaderView (which I'm not too surprised fails) and even QTableView to no avail.
I could (probably) get the header data from model()->headerData() but there are caveats when there's a QSortFilterProxyModel inbetween them. It will map QModelIndex but not a header index. :-/
-
Hi,
What about logicalIndexAt ?
-
I tried that. It's returning me an invalid index (row() & column() of -1).
-
Okay, logicalIndexAt() worked, when I used QMouseEvent::pos() and not QMosueEvent::globalPos(), so that was an error I overlooked.
I think what has to be done now is call mapToSource() when using a proxy, then call headerData().