[PyQt] vertical alignment of richtext in a table view

Mark Summerfield list at qtrac.plus.com
Tue Sep 7 14:32:49 BST 2010


On Tue, 7 Sep 2010 12:56:59 +0200
Wolfgang Rohdewald <wolfgang at rohdewald.de> wrote:
> On Dienstag 07 September 2010, Mark Summerfield wrote:
> > I should have mentioned before that it is better to inherit
> > from QStyledItemDelegate rather than QItemDelegate. I'd try
> > that first & see if that improves things at all.
> 
> makes no difference.

Maybe not, but still better practice.
 
> > 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.

> > Using QTextDocument is fine for computing the size hint,
> > although for efficiency you might create a class-level
> > QTextDocument and reuse it.
> 
> done.

Good.

> 
> > (There are other possibilities
> > too, that I cover in Advanced Qt Programming, but can't
> > recall off hand.)
> 
> just ordered. I hope it is as excellent as your book about
> rapid GUI programming with Python and Qt.

I hope so too:-D

> my latest version of this delegate is here:
> http://websvn.kde.org/trunk/KDE/kdegames/kajongg/src/genericdelegates.py?view=markup

I just looked at that and noticed that you're implementing a
GenericDelegate. That works fine, but Qt now allows you to set row- and
column-specific delegates so having a GenericDelegate is no longer
needed. Instead, just create the delegates that you need, e.g.,
RichTextDelegate, and set that on the row(s) and column(s) its needed
for.


-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
    C++, Python, Qt, PyQt - training and consultancy
        "Advanced Qt Programming" - ISBN 0321635906
            http://www.qtrac.eu/aqpbook.html


More information about the PyQt mailing list