Need QGraphicsScene signal or event for _after_ change
events, qgraphicsscene, qt, signals
Solution
`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.
Problem
I use `QGraphicsScene` of the Qt framework. Inside the scene I have some `QGraphicsItem`s which the user can select and move. I would like to have an info label where the current x and y coordinate of the currently moved selection (can consist of many items) is displayed. I have tried with the signal `changed` of `QGraphicsScene`. But it is fired before the x() and y() property of the items is set to the new values. So the labels always show the second-to-last coordinates. If one moves the mouse slowly, the display is not very wrong. But with fast moves and sudden stops, the labels are wrong. I need a signal that is fired after the scene hast changed. I have also tried to override the `itemChange` method of `QGraphicsItem`. But it is the same. It is fired before the change. (The new coordinates are inside the parameters of this method, but I need the new coordinates of all selected items at once) I have also tried to override the `mouseMove` events of `QGraphicsScene` and of `QGraphicsView` but they, too, are before the new coordinates are set. I did a test: I used a oneshot timer so that the labels are updated 100 ms after the signals. Then everything works fine. But a timer is no solution for me. What can I do? Make all items un-moveable and handle everything by my own?