Now, you need to add a Control Point (sub-item) on the parent item to adjust the shape of the parent item.
The key is that after the sub-item is moved, you must hand over its location information to the parent item so that the parent item can update its shape.
After checking the document of QT for a long time, you need to use setfilterschildevents (true) in the parent item to set to allow blocking of all messages to the Child item, and then reload this function:
bool sceneEventFilter ( QGraphicsItem * watched, QEvent * event )
{
If (watched-> type () = qgraphicsrectitem: type) // all of my sub-items are rect
{
if(event->type() == QEvent::GraphicsSceneMouseMove)
{
// Process mobile messages
}
else if(event->type() == QEvent::GraphicsSceneMouseRelease)
{
// Process the mouse release message
}
}
Return false; // false: the message of the sub-item will still be processed. If true is returned, the message of the sub-item will not be processed.
}
Solved this problem.
When reloading an item, make sure to determine whether it is the item you want to intercept.
Or you can use
InstallsceneeventfilterTo intercept messages of an item and specify the item to be filtered.
Reference: http://blog.csdn.net/fly542/article/details/6459661