【发布时间】:2018-04-27 16:57:55
【问题描述】:
我正在使用 QPainterPath 在 qgraphicsscene 上绘制一个多边形。但是,当我想删除路径后,我无法删除它。有人可以告诉我如何删除/擦除绘制的路径。 我正在尝试以下代码。
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();
}
谢谢。
【问题讨论】:
标签: qt qgraphicsscene