[PyKDE] Qt4: QPainter.drawText

Phil Thompson phil at riverbankcomputing.co.uk
Mon Apr 10 11:06:35 BST 2006


On Monday 10 April 2006 10:36 am, Patrick Stinson wrote:
> I'm trying to draw some text within a bounding rectange, and am
> running into a problem with the polymorhpic nature of
> QPainter.drawText.
>
> I see:
>
>     void drawText(const QPointF &p, const QString &s);
>     void drawText(const QRectF &r, int flags, const QString &text,
> QRectF *br /Out/ = 0);
>     void drawText(const QRect &r, int flags, const QString &text,
> QRect *br /Out/ = 0);
>     void drawText(const QRectF &r, const QString &text, const
> QTextOption &o = QTextOption());
>
> but I get:
>
>     painter.drawText(rect, 0 | Qt.AlignCenter, self.text(), rect)
> TypeError: too many arguments to QPainter.drawText(), 3 at most expected
>
> I've always wondered how sip dealt with these potentially confusing
> situations.

/Out/ arguments are returned (possibly as part of a tuple if there is more 
than one value to return).

You probably want...

    rect = painter.drawText(rect, Qt.AlignCenter, self.text())

Phil




More information about the PyQt mailing list