Hi, all, i sub class QStyledItemDelegate and re-implement the paint () function like this:
{
painter->save();
painter
->fillRect
(option.
rect,
QBrush(Qt
::red));
painter
->setPen
(QColor(Qt
::black));
painter->drawRect(option.rect);
painter->restore();
QStyledItemDelegate::paint(painter, option, text, false);
}
void CustomDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index)const
{
painter->save();
painter->fillRect(option.rect, QBrush(Qt::red));
painter->setPen(QColor(Qt::black));
painter->drawRect(option.rect);
painter->restore();
QStyledItemDelegate::paint(painter, option, text, false);
}
To copy to clipboard, switch view to plain text mode
Sadly the delegate paint the item beyond the boder of the QListView and looks like the attachment. I don't know why. The picture in the attachment is a screen shotcut when the cursor hover the area that is very near to the list veiw's bottom border, outside the view.
Any help and suggestions will be appreciated greatly, thank you in advance.
Bookmarks