Results 1 to 4 of 4

Thread: Save to SVG and load from it

  1. #1
    Join Date
    Jun 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation 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?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.

  3. #3
    Join Date
    Jun 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default 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?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.