Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to hover an entire row on mouseover in a QTableView?
zalan.szakolci last edited by
I subclassed QTableView, QAbstractTableModel, and QItemDelegate. I am able to hover a single cell on mouse over:
void SchedulerDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
if(option.showDecorationSelected &&(option.state & QStyle::State_Selected))
... but I cannot figure out, how to hover an entire row. Can Someone help me with sample codes?
Mystery Keeper last edited by
By "hovering" do you mean "highlighting"? Make a variable in the model that stores the row number under the mouse pointer and a method to set it. Set it every time mouse moves over the view. Make the model supply BackgroundRole data based on that variable. Also make it emit signal for the complete data update to the view. And be ready for constant view repaints.
Code_ReaQtor last edited by
I don't think there is such an implementation... but you can select entire row with setSelectionBehavior(QAbstractItemView::SelectRows)
You can do a simple "hack" by installing an eventFilter() to QTableView to capture hover events then get the row/index at mouse position.