我继承了 QTableView、QAbstractTableModel 和 QItemDelegate。我可以将鼠标悬停在单个单元格上:
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);
}
...
}
...但我不知道如何悬停整行。有人可以帮我提供示例代码吗?