Need QGraphicsScene signal or event for _after_ change

前端 未结 2 2177
既然无缘
既然无缘 2020-12-06 20:44

I use QGraphicsScene of the Qt framework. Inside the scene I have some QGraphicsItems which the user can select and move. I would like to have an i

2条回答
  •  借酒劲吻你
    2020-12-06 20:51

    QGraphicsItem::itemChange() is the correct approach, you were probably just checking the wrong flag. Something like this should work fine:

    QVariant::myGraphicsItem( GraphicsItemChange change, const QVariant &value )
    {
      if( change == QGraphicsItem::ItemPositionHasChanged )
      {
         // ...
      }
    }
    

    Note the use of QGraphicsItem::ItemPositionHasChanged rather than QGraphicsItem::ItemPositionChange, the former is called after the position changes rather than before.

提交回复
热议问题