I have an old c++ program that I need to bring back to life. My task now is to draw a single Polygon. I am stuck at the very beginning since I have no experience in graphics. The points I want to use to draw a Polygen are stored in
QVector < QPointF> points which looks like that:
Now I want to draw my Polygon. I use this code:
ggScene = new QGraphicsScene();
QPolygonF shape(points);
QGraphicsItem* gg = ggScene->addPolygon(shape);
When compiling I get the following error:
cannot convert QGraphicsPolygonItem* to QGraphiscItem in initialization
Can anybiody help me on this please, thank you.
I'm going to go out on a limb and guess that the actual error message is...
(Note
QGraphicsItem*
rather than justQGraphicsItem
)If that's the case then the problem is probably that the compiler is only seeing a forward declaration of
QGraphicsPolygonItem
. Hence it is not aware thatQGraphicsPolygonItem
inherits fromQGraphicsItem
and so cannot perform the implicit conversion fromQGraphicsPolygonItem*
toQGraphicsItem*
.The fix is probably the simple addition of...