[PyKDE] QTable and background color.

Gianluca tuxgame at email.it
Mon Oct 6 15:27:01 BST 2003


I am trying to implement a QTable where n cells on every row are painted on a 
different color.

Searching on the ML, I find that I must reimplement the paint method. Fine.
Now I have only one problem: the setting of the color is located in a for 
cicle (I don't know in advance what cell I must modify), but I only get a red 
background on the last cell I change.

This is the code i use:

for x in range(0,cols):
	self.tabella.setItem(barca, x, self.item)

(the for over the rows are external to this one)

and this is the implementation of the paint method:

class colorItem(QTableItem):
	def __init__(self, table, edittype, text):

	def paint(self, painter, colorgroup, rect, selected):
		cg = QColorGroup(colorgroup)
		cg.setColor(QColorGroup.Base, Qt.red)
		QTableItem.paint(self,painter, cg, rect, selected)

It works, but only for the last cell I update


QTable 6*10
I need to change 2 cell on every row.
All the cells I need to change lose the text, except for the last one, who 
mantain the correct text and have a red background.

Any hints ?



We are the opensource. Existence as you know it is over. We will add
your proprietary features and technological distinctiveness to own
opensource project. Resistence is futile. Windows is closed.

Email.it, the professional e-mail, gratis per te: http://www.email.it/f

Fare shopping con EmailConto Risparmio è facile e conveniente: con un solo click sconti tutti i tuoi acquisti!
Provalo adesso.
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=839&d=6-10

More information about the PyQt mailing list