Vino
Vino

Reputation: 177

Removing multiple items from QGraphicsScene

In my Qt GUI, I have QGraphicsScene where QGraphicsItems are added. Now in order to delete the items, I'm using GraphicsScene::selectedItems() to return a list of items selected on the screen. This returns the memory address of selected items, their position and flag as a comma separated array.

Now how do I use this result "QList<QGraphicsItem*> as an argument to QGraphicsScene::removeItem()?

UPDATE **** Item added to the scene is from a class derived from GraphicsItem. And each class creates a text file when the item saddled to the scene. So when this item is deleted the text file also should be deleted. If I'm gonna use the above method, I cant do that. Rather I prefer to get the object being selected by QGraphicsScene::selectedItems and then use the member function from the class to delete the file associated with it. How do I do this. Please explain thank you so much

Upvotes: 1

Views: 1374

Answers (1)

dtech
dtech

Reputation: 49289

foreach (QGraphicsItem * i, selectedItems()) removeItem(i);

Upvotes: 1

Related Questions