خرید بک لینک

Vote count: 0

I am populating a QGraphicsScene with instances of a custom item class (inherting QGraphicsPathItem). At some point during runtime, I try to remove an item (plus its children) from the scene by calling:

delete pItem;

This automatically calls QGraphicsScene::removeItem(), however it also leads to a crash in the class QGraphicsSceneFindItemBspTreeVisitor during the next repaint.

asked 24 secs ago

1 Answer

Vote count: 0

TL;DR: The solution is to ensure that QGraphicsItem::prepareGeometryChange() gets called before the item's removal from the scene.


The problem is that during the item removal from the scene, the scene inteal index was not properly updated, resulting in the crash upon the next attempt of drawing the scene.

Since in my case, I use a custom subclass from QGraphicsPathItem, I simply put the call to QGraphicsItem::prepareGeometryChange() into its destructor since I am not manually removing the item from the scene (via QGraphicsScene::removeItem()), but instead I simply call delete pItem; which in retu triggers the item's destructor as well as removeItem() later on.

answered 24 secs ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 29 تير 1395 ساعت: 19:52

صفحه بندی