Details
-
Suggestion
-
Resolution: Invalid
-
P3: Somewhat important
-
4.4.0
-
None
Description
A common pattern with custom item delegates is to draw a standard item background and then draw custom content on top. QItemDelegate in the past provided a drawBackground() method which could be used to do this. At the moment what I have done is copy the code from QStyledItemDelegate::paint() which casts the QStyleOptionViewItem to a suitable version, gets a suitable style using the associated widget or the application and then calls the QStyle::drawPrimitive() method. Since this is a common thing to want to do, a convenience method in QStyledItemDelegate would be useful.
I had to look at the QStyledItemDelegate implementation to find out how to get the appropriate QStyle since QStyleOptionViewItemV3 (which provides the associated QWidget*) does not appear in the documentation. Please could you add a mention of this to the QStyledItemDelegate documentation and also a note of which style primitives are used to draw parts of the item (PE_PanelItemViewItem, CE_ItemViewItem).