You could have a look into the sources of QAbstractItemView::setAlternatingRowColors(). It is not exactly what you want, but maybe it can give you some ideas.

Ginsengelf