You can do it from the delegate. The core of the functionality will be exactly the same as the one I posted above, you just need to place it in the delegate. Subclass QItemDelegate and reimplement its paint function. You should then insert the already mentioned code there (of course you need to change it slightly but the general idea remains) so that it changes the palette of the "option" param and then call the base class implementation to handle the rest.
It's possible that this will not work (depends if the default delegate looks at the palette to render the background -- I'm not sure of that). In that case just fill the background yourself using QPainter::fillRect() before calling the base implementation of the paint method.
Bookmarks