I am drawing a polygon on qgraphicsscene using QPainterPath. However after sometime when I want to delete the path I am unable to delete it. Can someone tell me how to delete/erase the drawn path. I am trying the following code.
In header File:
QGraphicsScene *scene;
QGraphicsPixmapItem *m_pixItem;
QPainterPath m_pathTrack;
QPolygon m_qpolygon;
In cpp file
void MyClass::AddPath()
{
//Slot to add path to the scene
QImage l_img("Path");
graphicsView->setScene(&scene);
m_pixtemItem->setPixmap(QPixmap::fromImage(image));
//Code here to Adding points to polygon. The points are coming at regular interval
m_qpolygon.append(Point);
m_pathTrack.addPolygon(m_qpolygon);
scene.addPath(m_pathTrack);
}
// In slot to delete path
void MyClass::DeletePath()
{
//I tried doing this but the path does not erase
m_pathTrack = QPainterPath();
}
Thank You.