In a scene with multiple groups, how can I delete the selected item group? When I try to delete the group, it only deletes the last created group.
#include "graphicscene.h"
QGraphicsItemGroup *mpGroup ;
void GraphicScene::keyReleaseEvent(QKeyEvent * keyEvent)
{
if( keyEvent->key() == Qt::Key_F1) {
qDebug() << "group created";
mpGroup = createItemGroup(selectedItems());
mpGroup->setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable);
qDebug() << "Group Address "<< mpGroup ;
} else if( keyEvent->key() == Qt::Key_F2) {
qDebug() << "Group Before delete selected item"<< selectedItems() ;
if(mpGroup != NULL) {
destroyItemGroup(mpGroup);
qDebug() << "Group Deleted "<< mpGroup ;
}
}
}