python - In Pyqt/PySide How to set different color in on cell of the TableView -


i data database , show on tableview.

in 1 cell keywords should more obvious user warnning critical , on.

i know how change font color of whole cell's words need red of them.

e.g.

warnning: trial period 20 days left

the words warnning , number 20 should color in red other words should black normal.

how to? thank much.

you need use model table view, returns cells red foreground color role foregroundrole. like:

class mymodel(qtcore.qabstracttablemodel):      def data(self, index, role):         if index.isvalid():             if role == qtcore.qt.foregroundrole , condition_for_red_color:                 return qtgui.qbrush(...) 

Comments