[PyKDE] Error when overloading QTable.paintCell

Phil Thompson phil at riverbankcomputing.co.uk
Fri Jun 13 18:37:01 BST 2003


On Friday 13 June 2003 5:17 pm, Frederick Polgardy Jr wrote:
> Weird, if you add the QColorGroup arg to both (the other overloaded version
> of the method), you then get the opposite exception!:
>
> ...
>     def paintCell(self, painter, row, col, rect, selected, cg):
>         QTable.paintCell(self, painter, row, col, rect, selected, cg)
> ...
>
> TypeError: paintCell() takes exactly 7 arguments (6 given)
>
> Could SIP be mixing up which version is getting mapped to which C++ method?

Remember that Python doesn't support methods with the same name but with 
different signatures - you have to handle this explicitly in code.

What you need to do is something like this...

	def paintCell(self, painter, row, col, rect, selected, cg = None):
		if cg:
			QTable.paintCell(self, painter, row, col, rect, selected, cg)
		else:
			QTable.paintCell(self, painter, row, col, rect, selected)

Phil




More information about the PyQt mailing list