Reputation: 595
Currently I have a class 'Polygon' which inherits QGraphicsItem. I have class 'PolygonFactory' which creates, and configures Polygons. The PolygonFactory reads information from a DB, and from that information it creates Polygons. My problem is that if I inherit QGraphicsItem, I have to specify it's shape as a constant, but I need the Polygons to be created on the fly. You may say "don't inherit QGraphicsItem" but I need to, because I need user interaction with the Polygons in my GraphicsScene. I hope I'm being clear, but if you need more information let me know.
Thanks.
Upvotes: 0
Views: 408
Reputation: 4022
You can paint whatever you want in your QGraphicsItem. I'd recommend subclassing the QGraphicsPathItem for this case.
When do your polygons change? Whenever that happens you can call setPath with your new shape.
Upvotes: 1