How can I change QT listview background from delegate? -


i have listview in form , have item delegate it. need changing item's background color in terms of something, item delegate.

ok let's have listview , filled list

"blue", "red", "green" 

on other hand have item delegate listview. need change items' background colors own colors.

you have overwrite paint(self, painter, option, index) function in delegate in order change way items painted.

for instance:

class mydelegate(qitemdelegate):      #...      def paint(self, painter, option, index):          painter.save()                   # can restore original painter later.         painter.setbrush(qbrush(qt.red)) # set background color.         painter.restore()                # restore original painter. 

what now?

now know how paint background need value of item being painted can decide color be. can use last argument of paint function, index, qmodelindex instance can use getting value you're looking for.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -