Results 1 to 2 of 2

Thread: posChanged() for QGraphicsItem?

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

    Default posChanged() for QGraphicsItem?

    Is it possible to detect changes in the position of a QGraphicsItem? I need to update other data when the position changes. I tried reimplementing all setPos functions, but when I drag an item across my graphics scene these functions are not called so the other data isn't updated.

  2. #2
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: posChanged() for QGraphicsItem?

    see QGraphicsItem::itemChange and enum QGraphicsItem::GraphicsItemChange value QGraphicsItem::ItemPositionHasChanged or QGraphicsItem::ItemScenePositionHasChanged (depending what you want). Note that you have to set a flag QGraphicsItem::ItemSendsGeometryChanges for the item (QGraphicsItem::setFlag).

    another thing there is a Qt bug for QGraphicsItem::ItemScenePositionHasChanged. You have to set flag ItemSendsGeometryChanges for all parents (to the root parent) to get proper notifications about scene position change.

  3. The following 2 users say thank you to MarekR22 for this useful post:

    blooglet (17th February 2011), corrado1972 (7th June 2011)

Similar Threads

  1. Replies: 7
    Last Post: 29th November 2010, 19:20
  2. Filling a QGraphicsItem
    By c_srikanth1984 in forum Qt Programming
    Replies: 15
    Last Post: 6th July 2009, 14:34
  3. Casting QGraphicsItem child from QGraphicsItem
    By patrik08 in forum Qt Programming
    Replies: 3
    Last Post: 29th August 2008, 15:37
  4. Replies: 2
    Last Post: 28th June 2008, 16:31
  5. how to hide QgraphicsItem !!!
    By peace_comp in forum Qt Programming
    Replies: 2
    Last Post: 24th May 2008, 09:46

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.