如何擦除图形屏幕中的绘图

时间:2012-05-16 12:35:12

标签: qt4

我正在QT中编写一个应用程序,它将在一个小部件中显示地图。并且它还会在给定坐标的情况下从起点到终点绘制一条路线。现在问题是我是否只想撤消绘制路线(我的意思是擦除)。以下代码片段将说明我的绘画方式。

    QGeoMapRouteObject *route = new QGeoMapRouteObject(reply->routes().at(0));
    QColor routeColor(Qt::blue);
    routeColor.setAlpha(127);
    QPen pen(routeColor);
    pen.setWidth(3);
    pen.setCapStyle(Qt::MPenCapStyle);
    route->setPen(pen);

此类“QGeoMapRouteObject”除了setPen之外没有其他选项。请告诉我如何使用此类“QGeoMapRouteObject”绘制和擦除路径。

1 个答案:

答案 0 :(得分:0)

QGeoMapRouteObject无法撤消该过程。因为它是被调用的对象。只调用Object(在您的情况下为Graphics视图)可以撤消效果。Just like Pixmap being an object and painter the parent object, Pixmap itself can't draw a Line in it.