[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] vertical alignment of richtext in a table view
From:       Mark Summerfield <list () qtrac ! plus ! com>
Date:       2010-12-19 8:18:45
Message-ID: 20101219081845.0453dca0 () dino
[Download RAW message or body]

Hi Wolfgang,

On Sat, 18 Dec 2010 18:56:36 +0100
Wolfgang Rohdewald <wolfgang@rohdewald.de> wrote:
> On Dienstag 07 September 2010, Mark Summerfield wrote:
> > > > The offset you need might be made up of the
> > > > option.decorationSize's width; not sure about the height
> > > > offset.
> > >
> > > 
> > >
> > > decorationSize is (16,16) - that does not explain it.
> > 
> > Then I'm not sure. Could try experimenting with the label's
> > indent, margin, and frameWidth.
> 
> now I found the problem.
> 
> This misplaces the text:
> 
> class RichTextColumnDelegate(QStyledItemDelegate):
>     label = QLabel()
>     def paint(self, painter, option, index):
> 		...
>         self.label.render(painter, option.rect.topLeft())
> 
> I have to do:
>         painter.save()
>         painter.translate(option.rect.topLeft())
>         self.label.render(painter)
>         painter.restore()

Yes, I just checked with the PyQt book's examples and that's almost the
same as what I do:

    def paint(self, painter, option, index):
        ...
        painter.save()
        ...
        painter.translate(option.rect.x(), option.rect.y())
        ...
        painter.restore()


-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
    C++, Python, Qt, PyQt - training and consultancy
        "Programming in Python 3" - ISBN 0321680561
            http://www.qtrac.eu/py3book.html
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic