resize a QGraphicsRectItem
Hi there
I have QGraphicsRectItem and I want to resize it , but I can't.
I tried this , but it doesnt work
Code:
QRectF rect
( player
->shape
()->pos
().
x() ,
(player->shape()->pos().y()+WINDOW_END_H)/2.0,
PLAYER_WIDTH_P,
PLAYER_HEIGHT_P/2.0);
player->shape()->setRect(rect);
player->shape() returns a QGraphicsRectItem *
I just want to change the hight of the rect to a half .
I tried this , too
Code:
player->shape()->rect().setHeight(player->shape()->rect().height() / 2.0 );
It doesnt work too .
Do you know what is the problem?
Re: resize a QGraphicsRectItem
hey please somebody answer my question :(
Re: resize a QGraphicsRectItem
QGraphicsRectItem::shape() returns copy of the QPainterPath object.
This method is to get the shape.
If you want resize the rect, you can use QGraphicsRectItem::setRect() instead.
or, you can override the QGraphicsRectItem::shape(), and return new shape.
Re: resize a QGraphicsRectItem
or, You can override the QGraphicsRectItem::boundingRect() too.
Re: resize a QGraphicsRectItem
QGraphicsRectItem::setRect() did it for me. Thanks!