【发布时间】:2018-12-27 05:29:48
【问题描述】:
在有多个组的场景中,如何删除选定的项目组? 当我尝试删除组时,它只会删除最后创建的组。
#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 ;
}
}
}
【问题讨论】:
标签: c++ qt qt5 qgraphicsscene qgraphicsitem