QTableView disable highlight on select, delegate not working
-
Hello,
I have some trouble with delegate which will disable highlight on item select in QTableView.
There is picture with problem(second item):
!http://www.sdilej.eu/pics/132f736eaa2ec37dfb5bc806d664752e.PNG(Problem)!Following code for delegate:
@class BGDelegate : public QStyledItemDelegate
{
public:
explicit BGDelegate(QObject* parent = 0) : QStyledItemDelegate(parent)
{
}void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { QVariant bg = index.data(Qt::BackgroundRole); if(bg.canConvert<QBrush>()) painter->fillRect(option.rect, bg.value<QBrush>()); QStyledItemDelegate::paint(painter, option, index); if(option.state & QStyle::State_Selected) { painter->save(); QPen pen(Qt::black, 2, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin); int w = pen.width() / 2; painter->setPen(pen); painter->drawRect(option.rect.adjusted(w, w, -w, -w)); painter->restore(); } }
};@
Thanks for reply and help!