Results 1 to 2 of 2

Thread: Prevent graphicsItem from being moved outside the boundary of defined scene

  1. #1
    Join Date
    Jul 2009
    Location
    Jordan, and UAE
    Posts
    55
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Prevent graphicsItem from being moved outside the boundary of defined scene

    Hello All,

    I'm writing an application that uses the QGraphicsRectItem as a base item of the scene, I can add to this item a QGraphicsPixmapItem items

    The items that are added can be moved, but what I want is to prevent the user from being able to move the items outside the boundary of the base item of the scene, now the user can move the item everywhere, and outside the boundary of the base item

    What do you suggest that I should do, is there any function that I need to re-implement or override?

    Thanks very much!

  2. #2
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Prevent graphicsItem from being moved outside the boundary of defined scene

    See QGraphicsItem::itemChange(). The example should be exactly what you want.

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.