nifei
5th February 2009, 06:26
Hi, all, i sub class QStyledItemDelegate and re-implement the paint () function like this:
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);
}
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.
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);
}
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.