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))
{
QColor color(255,255,130,100);
QColor colorEnd(255,255,50,150);
QLinearGradient gradient(option.rect.topLeft(),option.rect.bottomRight());
gradient.setColorAt(0,color);
gradient.setColorAt(1,colorEnd);
QBrush brush(gradient);
painter->fillRect(option.rect,brush);
}
...
}
... but I cannot figure out, how to hover an entire row. Can Someone help me with sample codes?
Here is my implementation,it works well.First you should subclass QTableView/QTabWidget ,emit a signal to QStyledItemDelegate in mouseMoveEvent/dragMoveEvent function .This signal will send the hovering index.
In QStyledItemDelegate ,use a member variable hover_row_(changed in a slot bind to above signal) to tell paint function which row is be hovered.
Here is the code examaple:
There are 2 ways..
you can also tried style sheet:
Hope, It will usefull to you guys.