2

I want to subclass QStyledItemDelegate and modify it with QStyleSheets. I dont have any clue of how to get it to work. I tried plenty of hours to just display anything, looking like I defined in the qss. In priciple it has to work, because when I call the base class implementation of paint(QPainter*, const QStyleOptionViewItem &, const QModelIndex&) the list items look like defined. Well, now how can I apply the stylesheet in the delegate?

ManuelSchneid3r
  • 15,850
  • 12
  • 65
  • 103

1 Answers1

2

Everything has to be done through QStyle. E.g. in a QListView to draw the background:

QStyle *style = option.widget->style();
style->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter, option.widget);

There are a lot of other drawXYZ(..) functions. See QStyle docs.

ManuelSchneid3r
  • 15,850
  • 12
  • 65
  • 103