[PyKDE] alignment in table

Jim Bublitz jbublitz at nwinternet.com
Fri May 12 17:56:54 BST 2006


On Friday 12 May 2006 07:03, Behnam Kamrani wrote:
> Sorry for another trivial post..., but have difficulties to (center)
> align cells in a table. Does anybody have an example to look at?
>
> There was a post which discussed that, but even that is not enough for me:(
> http://www.mail-archive.com/pykde@mats.imk.fraunhofer.de/msg00161.html

I'm assuming this is still Qt3 - I haven't looked at Qt4. Here's a comment 
from one of my apps that uses QTable/QTableItem and wants numbers 
right-aligned. The basic idea should be the same to center, or do arbitrary 
alignment. This method is in a class that subclasses QTableItem:

    def alignment (self):
        # QTableItem has no setAlignment method yet (as is pointed out in
        # a comment in the source) This is a way to force our numbers to
        # right align. The logic here could be expanded to allow choice of
        # alignments. The methods that draw text in cells call alignment()
        # to get the alignment setting. The  alternative to this is to
        # overload the text drawing methods. This is easier.

        return Qt.AlignRight

Jim




More information about the PyQt mailing list