Save to SVG and load from it
Hello
I'm using QT 4.3.2 with MS VS 2005
I need to create a simple analogue of CorelDRAW (with drawing of lines, circles, their selecting, dragging, scene zooming etc). With the power of QGraphicsScene/View/Item classes it seems to be simple, but..Well, saving to SVG file also seems (judging by the documentation of QSvgGenerator) trivial, but the docs of QGraphicsSvgItem seem to be very disappointing, as the whole SVG file will be presented as single item on the scene. So I'll lose ability to select and edit of my lines and squares as they will be parts of one big QGraphicsSvgItem. So, what to do? :(
Re: Save to SVG and load from it
You have to parse the svg file manually and recreate all items based on the contents of the file. This is not a trival task and it might be simpler for you to save your scene in a custom data format instead of svg.
Re: Save to SVG and load from it
damn...till today Qt seemed a "perfect" library to me. I think it's because SVG module is relatively young. Or is my request so narrow-applicable? If not, is it possible to submit a "petition" to Trolltech to implement more deep integration between QGraphicsXXX classes and SVG module in the next version of Qt? :)
Re: Save to SVG and load from it
But what kind of deep integration? SVG files are really XML files. If you need to extract its contents, just parse the file and interprete the tags. SVG in Qt is treated as a scalable image, not as a set of separate objects. Based on the fact that only a subset of SVG is supported by Qt, I don't think any petitions will have any influence :)