qt - Crash when delete QGraphicsItem -
i want remove items in qgraphicsscene , delete them. this,
qgraphicsitem * item = null; foreach(item, scene->items()) { scene->removeitem(item); delete item; }
however, crashed segmentation fault after running block of codes , getting out loop. , in debug mode, debugger jumped assembly file: what's going wrong?
if deleting items scene, why dont "clear" shown below. have scene object right.
scene-> clear();
as per documentation: void qgraphicsscene::clear()
removes , deletes items scene, otherwise leaves state of scene unchanged.
this function introduced in qt 4.4.
Comments
Post a Comment