Solved Find which item QGraphicsItem corresponds to
-
I have functions to add a rectangle and to add some text to a QGraphicsScene, which then stores the pointer to its corresponding list.
Eg:
QGraphicsTextItem *text = QGraphicsScene::addText(text, font); textItems.append(text)
Eg 2:
QGraphicsRectItem *rectangle = QGraphicsScene::addRect(newRectangle, pen); rectItems.append(rectangle)
Is it possible when selected to find out which item was selected based on QGraphicsItem* returned from
ImageEditor::selectedItems()
Eg:
QGraphicsItem *selectedItem = ImageEditor::selectedItems().at(0); // Code to correspond items to either an item in textItems or rectItems
-
Hi
The https://doc.qt.io/qt-5/qgraphicsitem.html#type
should return different types.
Try to qDebug it and see. -
Hi
The https://doc.qt.io/qt-5/qgraphicsitem.html#type
should return different types.
Try to qDebug it and see.