You don't have to do any custom painting. Just subclass QItemDelegate and reimplement its drawDisplay and drawDecoration methods calling the base class implementation with a reduced rectangle.
QItemDelegate::drawDecoration(painter, option, rect.
adjusted(2,
2,
0,
-2), pixmap
);
}
void MyItemDelegate::drawDecoration ( QPainter * painter, const QStyleOptionViewItem & option, const QRect & rect, const QPixmap & pixmap ) const {
QItemDelegate::drawDecoration(painter, option, rect.adjusted(2,2,0, -2), pixmap);
}
To copy to clipboard, switch view to plain text mode
You can also reimplement sizeHint to make sure the item is bigger than is needed to fit the text and icon.
Bookmarks