void
MyDelegate
::paint( QPainter* painter,
const QStyleOptionViewItem
& option,
const QModelIndex
& i
) const
{
// Special treatment for the selected state
if (option.
state & QStyle::State_Selected) {
QRect selectedRect
= option.
rect;
selectedRect.setLeft(0);
QLinearGradient linearGradient
(0, selectedRect.
top() ,
0, selectedRect.
top() + 100);
linearGradient.
setColorAt(0.0,
QColor(93,
148,
214));
linearGradient.
setColorAt(0.2,
QColor(25,
86,
173));
painter->setBrush(linearGradient);
painter->fillRect(selectedRect, linearGradient);
// But this is not convenient because it makes me need to reimplement also
// the display of the check box, decoration, text,...
.....
.....
} else {
}
}
void
MyDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& i ) const
{
// Special treatment for the selected state
if (option.state & QStyle::State_Selected) {
QItemDelegate::paint( painter, option, i );
QRect selectedRect = option.rect;
selectedRect.setLeft(0);
QLinearGradient linearGradient(0, selectedRect.top() , 0, selectedRect.top() + 100);
linearGradient.setColorAt(0.0, QColor(93,148,214));
linearGradient.setColorAt(0.2, QColor(25,86,173));
painter->setBrush(linearGradient);
painter->fillRect(selectedRect, linearGradient);
// But this is not convenient because it makes me need to reimplement also
// the display of the check box, decoration, text,...
.....
.....
} else {
QItemDelegate::drawBackground( painter, option, i );
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks