Qt – changing cell background color in qt

pyqtpyqt4qtqt4qtablewidget

i'm new to pyqt , and i'm still facing some newbie problems 😀
i have a QTableWidget that is item delegated on a QChoice control ( hope i said it right )
i need to have the cell background color changes whenever a user change the choice control selection

briefly: how to change a cell background color in a table widget ??

i use pyqt4 and python 2.6

thanx in advance

Best Answer

I used something like this:

brush = QtGui.QBrush(QtGui.QColor(255, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
item.setBackground(brush)

Where item is QTableWidgetItem object

Related Topic