PDA

View Full Version : How to draw selection in delegate



yogeshm02
25th May 2008, 17:29
Hi
I've implemented a custom item delegate. It is working good; the only problem is that i still want the selection to be drawn by the style.
I've looked into sources and seen that QStyledItemDelegate uses
style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, widget);
for its work.

But having above line in my delegate's painter seems twice the work [given that everything else except selection is drawn by this custom delegate (btw QStyledItemDelegate is not enough for me)]. Do you have any better idea to draw *only* the selection for the item?

jpn
25th May 2008, 20:24
Try QStyle::drawPrimitive(QStyle::PE_PanelItemViewItem ).