In this example:
http://www.java2s.com/Code/Cpp/Qt/InteractwithQGraphicsItem.htm
the itemChange() function is where all of the updating work takes place. However, this function doesn’t seem to be called when I move the handles around. According to:
http://doc.qt.io/qt-4.8/qgraphicsitem.html#itemChange
it should be called whenever the state changes, which I would imagine would include the position. Can anyone explain how to make this function get called when the handles are moved?
From the qt documentation check the
QGraphicsItem::ItemPositionChange:So you should enable the flag
QGraphicsItem::ItemSendsGeometryChangesin order to have theitemChangecalled when the position changes.By default this is disabled for optimization:
In order to set a flag you should call the
setFlagfunction preferably in the constructor of your custom item.