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. QSvgWidget not displaying file completely

QSvgWidget not displaying file completely

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 3 Posters 1.5k Views 1 Watching
  • 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.
  • W Offline
    W Offline
    wavelike
    wrote on last edited by
    #1

    Hello everyone,

    I have an SVG file which I want to show in an application window, and for that I am using (trying to) QSvgWidget. I get to see the graphics, but not all of it, as the legend, title and axis labels and markers are all missing.
    I am showing both images - the original with all information present and then what is displayed by a QSvgWidget.
    Any idea how to solve this problem? At the moment I am not looking at moving away from SVG, so I am primarily interested in fixing this problem, if it's possible.
    Thanks.
    (The image is generated by the Cairo package in R, if that is of any importance, though I have a feeling that has nothing to do with the problem)

    _plotViewer = new QSvgWidget(this);
    _plotViewer->load(graphicsFile);
    

    where graphicsFile is just a QString with the SVG filename.

    svg_original_800.PNG svg_incomplete_800.PNG

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

      Hi
      Qt only supports a subset of SVG. called mini or something like that.
      It might be its simply not support if it uses something advanced.

      B 1 Reply Last reply
      4
      • mrjjM mrjj

        Hi
        Qt only supports a subset of SVG. called mini or something like that.
        It might be its simply not support if it uses something advanced.

        B Offline
        B Offline
        Bonnie
        wrote on last edited by Bonnie
        #3

        @mrjj said in QSvgWidget not displaying file completely:

        called mini or something like that.

        You make me curious. So I looked into the doc. It's called Tiny :)

        Qt supports the static features of SVG 1.2 Tiny. ECMA scripts and DOM manipulation are currently not supported.

        1 Reply Last reply
        5
        • W Offline
          W Offline
          wavelike
          wrote on last edited by
          #4

          Well, that's disappointing,.. I wasn't expecting that. I guess I will have to abandon the idea of using SVG after all.

          Thanks to both of you.

          mrjjM 1 Reply Last reply
          0
          • W wavelike

            Well, that's disappointing,.. I wasn't expecting that. I guess I will have to abandon the idea of using SVG after all.

            Thanks to both of you.

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

            @wavelike
            Yeah it kinda sucks since it just looks like some text etc so I would have guessed it was covered by the Tiny specs.

            Could i get the image to have a look at?
            (dont upload here it's broken)

            W 1 Reply Last reply
            0
            • mrjjM mrjj

              @wavelike
              Yeah it kinda sucks since it just looks like some text etc so I would have guessed it was covered by the Tiny specs.

              Could i get the image to have a look at?
              (dont upload here it's broken)

              W Offline
              W Offline
              wavelike
              wrote on last edited by
              #6

              @mrjj Sure, just tell me how to send it to you

              mrjjM 1 Reply Last reply
              0
              • W wavelike

                @mrjj Sure, just tell me how to send it to you

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

                @wavelike
                You can use
                https://wetransfer.com/
                use the ... button
                alt text
                to send as link
                alt text

                and paste link here.

                all free. no registration needed.

                1 Reply Last reply
                0
                • W Offline
                  W Offline
                  wavelike
                  wrote on last edited by
                  #8

                  Here it is
                  https://we.tl/t-DBVDCAfDvm

                  mrjjM 1 Reply Last reply
                  0
                  • W wavelike

                    Here it is
                    https://we.tl/t-DBVDCAfDvm

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

                    @wavelike
                    Thank you. that was fast :)

                    mrjjM 1 Reply Last reply
                    0
                    • mrjjM mrjj

                      @wavelike
                      Thank you. that was fast :)

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

                      Hi
                      It seems the texts are not real text objects but some sort of path pr letter. (maybe the glyphs)

                      Maybe there is some options in Cairo package that allows to use text object instead ?

                      Seems other noticed this
                      https://stackoverflow.com/questions/18258654/r-inkscape-text-labels-in-svg-graphics-exported-from-r-did-not-recognized-as
                      and https://cran.r-project.org/web/packages/svglite/index.html
                      can be used to export as text but not sure it fit rest of your use case :)

                      W 2 Replies Last reply
                      2
                      • mrjjM mrjj

                        Hi
                        It seems the texts are not real text objects but some sort of path pr letter. (maybe the glyphs)

                        Maybe there is some options in Cairo package that allows to use text object instead ?

                        Seems other noticed this
                        https://stackoverflow.com/questions/18258654/r-inkscape-text-labels-in-svg-graphics-exported-from-r-did-not-recognized-as
                        and https://cran.r-project.org/web/packages/svglite/index.html
                        can be used to export as text but not sure it fit rest of your use case :)

                        W Offline
                        W Offline
                        wavelike
                        wrote on last edited by
                        #11

                        @mrjj Yes, that surprised me too, as I wanted to look at the part of the file where the legend/title/other text is located and the search came back empty. My knowledge of graphics files, including SVG, is next to non-existant, so I wasn't exactly shocked. Furthermore, just thinking about something called vector graphics, the ignorant me imagines that the file does not contain letters but relative positions of pixels or whatever... I'd better shut up, because I don't know what I am talking about haha.

                        1 Reply Last reply
                        1
                        • mrjjM mrjj

                          Hi
                          It seems the texts are not real text objects but some sort of path pr letter. (maybe the glyphs)

                          Maybe there is some options in Cairo package that allows to use text object instead ?

                          Seems other noticed this
                          https://stackoverflow.com/questions/18258654/r-inkscape-text-labels-in-svg-graphics-exported-from-r-did-not-recognized-as
                          and https://cran.r-project.org/web/packages/svglite/index.html
                          can be used to export as text but not sure it fit rest of your use case :)

                          W Offline
                          W Offline
                          wavelike
                          wrote on last edited by
                          #12

                          @mrjj Ok, I will have a look. I have already produced PNG files and will be working with them, unless I find a solution that will give me SVG in Qt without much extra work.

                          Thank you a lot, either way. :)

                          mrjjM 1 Reply Last reply
                          1
                          • W wavelike

                            @mrjj Ok, I will have a look. I have already produced PNG files and will be working with them, unless I find a solution that will give me SVG in Qt without much extra work.

                            Thank you a lot, either way. :)

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

                            @wavelike
                            Hi
                            Well a hires PNG should also work nicely.
                            Just for info. SVG is vector which means its not pixels but drawing functions so it can scale
                            without becoming pixellated. However, Cairo seems to not excatly insert the letters as letter but some form of another drawing thing that Qt cant draw.

                            SVG would look better if you were to print it on really hires printer or in A3 but in other cases, the PNG will look just as fine if you make sure its not lowres.

                            1 Reply Last reply
                            1
                            • W Offline
                              W Offline
                              wavelike
                              wrote on last edited by
                              #14

                              Just in case somebody stumbles upon this thread and also tried to use the Cairo SVG package with QSvgWidget - forget about Cairo as nice as it sometimes could be, as there is an R package ggiraph with a simple function dsvg(filename,...) and it produces a SVG file that is fully supported by Qt.

                              1 Reply Last reply
                              2

                              • Login

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