Results 1 to 2 of 2

Thread: Add Offset/Border/Boundary between QGraphicsScene and QGraphicsItem

  1. #1
    Join Date
    Mar 2012
    Location
    India
    Posts
    22
    Thanks
    3
    Qt products
    Qt4

    Default Add Offset/Border/Boundary between QGraphicsScene and QGraphicsItem

    Hi,
    I have a QGraphicsScene containing many custom QGraphicsItem.
    All the QGraphicsItems are movable. When I move the QGraphicsItem towards any edge of the QGraphicsScene the scene automatically expands.

    My problem is that I want to have some offset ( a kind of border ) between the scene and the graphics item, so that when I move the item to the edge of the scene the scene should expand with the offset in place.

    I tried using QGraphicsScene::setSceneRect(), but using this method freezes the size of the scene, so the scene doesnt expand automatically on graphics item move.

    Any pointers would be helpful.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,319
    Thanks
    316
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Add Offset/Border/Boundary between QGraphicsScene and QGraphicsItem

    Change the custom graphics item so that the boundingRect() method returns the rect + border instead of just the rect of the item.

    Or center the custom item as a child inside a QGraphicsRectItem whose size is adjusted to include the border. This might be more flexible, because then you can change the rect item's size and the position of the custom item inside it without affecting the custom item itself.

Similar Threads

  1. QFrame with border-radius inside QGraphicsScene
    By DeRatizator in forum Qt Programming
    Replies: 2
    Last Post: 23rd August 2010, 08:39
  2. Resize Border for QGraphicsItem
    By william.dias in forum Qt Programming
    Replies: 2
    Last Post: 8th February 2008, 09:19
  3. QPrinter on QGraphicsScene Border Problem
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 14th November 2007, 15:49
  4. QGraphicsItem-QGraphicsScene
    By hgedek in forum Qt Programming
    Replies: 5
    Last Post: 4th August 2007, 12:35
  5. Setting QGraphicsItem setSelected border color
    By forrestfsu in forum Qt Programming
    Replies: 1
    Last Post: 4th November 2006, 08:22

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
  •  
Qt is a trademark of The Qt Company.