I want to extend QGraphicsItem to add “QString toXML()” and “void fromXML(QString xml)” to all of my custom GraphicsItem widgets. What is the best way to this? The reason for wanting to this, is to iterate through all of my GraphicsScene and save the graphicsScene and restore the graphicsScene. The way I have to do this now is to determine the type and then cast the item to the right widget object. However, it would be much nicer not to determine the type and to cast.
I was thinking, maybe the best way is to make my own base Class that inherits QGraphicsItem. However my custom widgets don’t directly inherit QGraphicsItem but rather QGraphicsEllipseItem, QGraphicsRectItem, QGraphicsPolygonItem…etc. Any suggestions?
↧