qt-interest@trolltech.com
[Top] [All Lists]

Re: Problem with QGraphicsTextItem

Subject: Re: Problem with QGraphicsTextItem
From: RZ
Date: Mon, 14 Apr 2008 16:23:40 +0200
And for answering my own problem:
the correct signature is

QRectF GETextItem::boundingRect() const

then everything works like a charme.

Hi,

i got a little problem regarding QGraphicsTextItem: i just want such an item with a border drawn and a definite margin between border and text.

So i did:

void GETextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0)
{
painter->drawRoundedRect(0, 0, boundingRect().width(), boundingRect().height(), 5, 5);
    QGraphicsTextItem::paint(painter, option, widget);
}

QRectF GETextItem::boundingRect()
{
    const QRectF t = QGraphicsTextItem::boundingRect();
    QRectF t2;
    t2.setHeight(t.height()+20);
    t2.setWidth(t.width()+20);
    return t2;
}

QPainterPath GETextItem::shape() const
{
    const QRectF t = QGraphicsTextItem::boundingRect();
    QRectF t2;
    t2.setHeight(t.height()+20);
    t2.setWidth(t.width()+20);
    QPainterPath path;
    path.addEllipse(t2);
        return path;
}

This draws the border (with margin) but if i move the item the 'bottom' - the area outside the usual QGraphicsTextItem - is not redrawn (so there are points left).

What am i doing wrong?

Thx for any help,

RZ

--
To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
"unsubscribe" in the subject or the body.
List archive and information: http://lists.trolltech.com/qt-interest/

<Prev in Thread] Current Thread [Next in Thread>