Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Implementing SVG Editor with Qt > 5.x
QtWS25 Last Chance

Implementing SVG Editor with Qt > 5.x

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 5 Posters 2.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xtingray
    wrote on last edited by xtingray
    #1

    Hi,
    I have been researching about how to load and edit an SVG file from Qt.

    I'm already aware that it's possible to load an SVG file created using an editor like Inkscape and that you can render and save a QGraphicsScene as an SVG file. My challenge is in the middle of the workflow: is it possible to edit the nodes of an SVG element that is part of an SVG file that I just loaded from a Qt implementation?

    I was looking for examples related to the edition process with no luck. Is it possible to transform SVG items as QGraphicsItems to modify them? or any other approach in that direction?

    Thank you for any hint.


    Qt Developer

    raven-worxR 1 Reply Last reply
    0
    • X xtingray

      Hi,
      I have been researching about how to load and edit an SVG file from Qt.

      I'm already aware that it's possible to load an SVG file created using an editor like Inkscape and that you can render and save a QGraphicsScene as an SVG file. My challenge is in the middle of the workflow: is it possible to edit the nodes of an SVG element that is part of an SVG file that I just loaded from a Qt implementation?

      I was looking for examples related to the edition process with no luck. Is it possible to transform SVG items as QGraphicsItems to modify them? or any other approach in that direction?

      Thank you for any hint.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @xtingray said in Implementing SVG Editor with Qt > 5.x:

      is it possible to edit the nodes of an SVG element that is part of an SVG file that I just loaded from a Qt implementation?

      no, and this is by far not a trivial task
      You will need to parse each SVG (XML) node and create a custom item with corresponding handles. When saving the changes you will need to transform your items back to a valid SVG.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      2
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi
        If you need to handle more than a few SVG elements/constructs, using a lib is
        recommended.
        http://svgpp.org/

        Also, can I ask what types of edit you need to perform ?

        X 1 Reply Last reply
        1
        • mrjjM mrjj

          Hi
          If you need to handle more than a few SVG elements/constructs, using a lib is
          recommended.
          http://svgpp.org/

          Also, can I ask what types of edit you need to perform ?

          X Offline
          X Offline
          xtingray
          wrote on last edited by
          #4

          @mrjj The goal is to allow users to load SVG files from my application to make little changes to the objects, including to edit the nodes of the elements, change their colors, group and ungroup , etc.

          I'm aware this is not a trivial implementation, I'm just researching what is the state of the art related to SVG edition from Qt.


          Qt Developer

          raven-worxR 1 Reply Last reply
          0
          • X xtingray

            @mrjj The goal is to allow users to load SVG files from my application to make little changes to the objects, including to edit the nodes of the elements, change their colors, group and ungroup , etc.

            I'm aware this is not a trivial implementation, I'm just researching what is the state of the art related to SVG edition from Qt.

            raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by raven-worx
            #5

            @xtingray said in Implementing SVG Editor with Qt > 5.x:

            I'm just researching what is the state of the art related to SVG edition from Qt.

            simple: there is none :)
            Qt's SVG capabilities are just in displaying them.

            The rest can be achieved by parsing the XML source of the SVG.

            So my advice to start with:

            1. learn the SVG specification (as much as you can)
            2. learn Qt's XML classes
            3. then think about creating an appropriate structure to read the SVG data into
            4. use this structure for manipulating via UI elements (QtWidgets, QML)
            5. save the structure back to valid SVG

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            2
            • P Offline
              P Offline
              Parvathy2020
              wrote on last edited by Parvathy2020
              #6

              @mrjj Can we confirm that editing SVG file with Qt is not a good option ?

              mrjjM W 2 Replies Last reply
              0
              • P Parvathy2020

                @mrjj Can we confirm that editing SVG file with Qt is not a good option ?

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @Parvathy2020

                Hi
                Yes we can confirm
                that out of the box,
                Qt editing features for SVG is very limited.

                We can edit an SVG in a generic way (since its XML)
                but for anything more serious than changing a
                color, using a lib will be much more fun/rewarding/easy.

                1 Reply Last reply
                0
                • P Parvathy2020

                  @mrjj Can we confirm that editing SVG file with Qt is not a good option ?

                  W Offline
                  W Offline
                  wrosecrans
                  wrote on last edited by
                  #8

                  @Parvathy2020 said in Implementing SVG Editor with Qt > 5.x:

                  @mrjj Can we confirm that editing SVG file with Qt is not a good option ?

                  Editing an SVG "with Qt" just isn't an option. Qt is a general purpose framework, and being a graphics editor is too specific to be useful to have as part of a general purpose tool set. By all means, feel free to use Qt for XML parsing, and for the GUI, etc. It'll work fine as some parts of a graphics editor. But you'll need to write the actual graphics editor parts.

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved