[PyKDE] Aligning Text in a Table

Bob Parnes rparnes at megalink.net
Sat Jun 28 15:05:00 BST 2003


On Fri, Jun 27, 2003 at 05:18:07PM +0200, Simon Edwards wrote:
> Hi,
> 
> On Friday 27 June 2003 16:49, Bob Parnes wrote:
> > Sorry for posing trivial questions, but I do not understand how to use
> > paintCell. Attached is a demo to right-align text in a table cell.
> > There is no error message, but the code is ignored. So I assume that I
> > misinterpreted the documentation.
> 
> You've got yourself fairly mixed up. The idea is that you subclass QTable 
> (i.e. FooTable), and reimplement the paintCell() method. When Qt wants your 
> FooTable to paint a cell it will call your paintCell() method and pass in a 
> QPainter object. In paintCell() you then draw the cell contents on the 
> QPainter object that you received.
> 
> cheers,
> 
> -- 
> Simon Edwards             | Guarddog Firewall
> simon at simonzone.com       | http://www.simonzone.com/software/
> Nijmegen, The Netherlands | "ZooTV? You made the right choice."
> 
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.imk.fraunhofer.de
> http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

Thanks for your response. I got lost trying to follow your idea. In the
past I have subclassed my own classes and reimplemented methods in order
to make changes suiting the subclass. But here I cannot even make the
simplest reimplementation of paintCell. For example, the method,

  def paintCell(self,p,row,col,r,selected):
        QTable.paintCell(self,p,row,col,r,selected)

produces an error message (13 times, yet):
  TypeError: paintCell() takes exactly 6 arguments (7 given)

Furthermore, I don't know how to identify the QPainter object that Qt
passes. I could not find any place in the documentation that describes
how to do this. In my attempt above, I created one.

I did try other approaches, but they did not work either. If you could
suggest a reference to code, I would be grateful. Thanks.
	  
-- 
Bob Parnes
rparnes at megalink.net




More information about the PyQt mailing list