QML Serialization
-
wrote on 6 Apr 2011, 12:54 last edited by
I have to serialize whole scene rendered with QDeclarativeView, what's the best approach?
Do I have to write it from a scratch? -
wrote on 6 Apr 2011, 14:03 last edited by
Could you go into a bit more detail on what you want to achieve?
-
wrote on 6 Apr 2011, 14:32 last edited by
Sure:
I have a QML application in which I create 2D boxes (Rectangles) - each box can be opened and contain other boxes and so on - now I need to save the whole box-tree into a file, so I could load and reuse it later.
I couldn't find anything about serialization in QML - do I have to write own parser in C++ which would read my QML tree or is there any easier way? -
wrote on 6 Apr 2011, 14:45 last edited by
It is very hard to give sound advice on this, because I have no clue how your app works internally. My first instinct would be to keep track of the state of your rects outside of QML.
-
wrote on 6 Apr 2011, 15:53 last edited by
I think you have to write from scratch. There is a QDataStream class in Qt which helps creating your own binary serialization. I think most basic Qt types support QDataStream. Check out QObject::children() and QDeclarativeView::rootObject. Goot luck, would be nice to hear about your solution.
1/5