How to hover an entire row on mouseover in a QTableView?
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?
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.
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.