[PyQt] vertical alignment of richtext in a table view

Wolfgang Rohdewald wolfgang at rohdewald.de
Sat Dec 18 17:56:36 GMT 2010


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()

-- 
Wolfgang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20101218/0387d5a2/attachment.html>


More information about the PyQt mailing list