PDA

View Full Version : Saving QGraphics Scene items



chaltier
3rd April 2012, 05:24
Hi guys,

I have a bunch of QGraphicsTextItems, QGraphicsLineItems added to the scene..and i am trying to do a save/load function

What i did now was creating 2 different QList specifically for textItems and lineItems..

So if there are new item type, i will create a new QList specifically for them..

When i save the item, i have to do a for loop for each QList, and can be quite tedious if more new item type..

Is there any more efficient method like creating only 1 container to store all the objects? and how do i differentiate the different type of objects when they are called in the same container?

Thanks...

ChrisW67
3rd April 2012, 06:35
All the objects are QGraphicsItems so you could use a single container of QGraphicsItem*. You be able to distinguish them by their QGraphicsItem::type() and using qgraphicsitem_cast