Results 1 to 5 of 5

Thread: resize a QGraphicsRectItem

  1. #1
    Join Date
    Jan 2010
    Posts
    18
    Thanks
    11
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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
    Qt Code:
    1. QRectF rect ( player->shape()->pos().x() ,
    2. (player->shape()->pos().y()+WINDOW_END_H)/2.0,
    3. PLAYER_WIDTH_P,
    4. PLAYER_HEIGHT_P/2.0);
    5.  
    6. player->shape()->setRect(rect);
    To copy to clipboard, switch view to plain text mode 

    player->shape() returns a QGraphicsRectItem *

    I just want to change the hight of the rect to a half .

    I tried this , too
    Qt Code:
    1. player->shape()->rect().setHeight(player->shape()->rect().height() / 2.0 );
    To copy to clipboard, switch view to plain text mode 

    It doesnt work too .

    Do you know what is the problem?

  2. #2
    Join Date
    Jan 2010
    Posts
    18
    Thanks
    11
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: resize a QGraphicsRectItem

    hey please somebody answer my question

  3. #3
    Join Date
    Nov 2007
    Posts
    31
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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.
    kichi

  4. The following user says thank you to kichi for this useful post:

    blooglet (10th February 2011)

  5. #4
    Join Date
    Nov 2007
    Posts
    31
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: resize a QGraphicsRectItem

    or, You can override the QGraphicsRectItem::boundingRect() too.
    kichi

  6. #5
    Join Date
    Nov 2010
    Posts
    77
    Thanks
    17
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: resize a QGraphicsRectItem

    QGraphicsRectItem::setRect() did it for me. Thanks!

Similar Threads

  1. QGraphicsRectItem
    By c_srikanth1984 in forum Qt Programming
    Replies: 1
    Last Post: 29th July 2009, 10:04
  2. QGraphicsRectItem and QGraphicsTextItem.
    By cydside in forum Qt Programming
    Replies: 13
    Last Post: 20th July 2009, 13:11
  3. How can I use QGraphicsRectItem?
    By learning_qt in forum Qt Programming
    Replies: 3
    Last Post: 14th January 2009, 11:00
  4. Replies: 2
    Last Post: 22nd January 2008, 17:10
  5. QGraphicsRectItem::rotate()
    By LestorN in forum Qt Programming
    Replies: 1
    Last Post: 20th October 2006, 11:17

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.