Search code examples
qtsvginkscape

SVG Loading Black In QT


I am trying to load an svg image in Qt, but it keeps showing up black. I open the example project 'SVGViewer' and load my file, so the code should not be a problem as it works for the svg files included with the example.

I made my svg in Inkscape v0.91 and I have tried saving it as Inkscape svg and as a plain svg format and both show up black. All I included was a plain line of text just to see if I could get it to load.

Is there some other Inkscape setting I need to set to make it show up properly?

EDIT:

It may be helpful to see my svg file

Test SVG File

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   version="1.1"
   id="svg2"
   viewBox="0 0 744.09448819 1052.3622047"
   height="297mm"
   width="210mm">
  <defs
     id="defs4" />
  <metadata
     id="metadata7">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title></dc:title>
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     id="layer1">
    <flowRoot
       style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
       id="flowRoot3336"
       xml:space="preserve"><flowRegion
         id="flowRegion3338"><rect
           y="149.50507"
           x="62.857143"
           height="54.285713"
           width="162.85715"
           id="rect3340" /></flowRegion><flowPara
         id="flowPara3342">ABC123</flowPara></flowRoot>  </g>
</svg>

Solution

  • <flowRoot>, <flowRegion> etc are SVG 1.2 elements. I believe that Inkscape is the only program that currently supports the flowing text features of SVG 1.2. No browsers do, and I don't know of any other SVG renderers that do either.

    It is fine to use those flowing text features of Inkscape to design your SVG files. But if you to want them to work with other renderers, you will need to convert those flowing text blocks to normal text elements before you save the files.

    For how to do that, see the instructions at the bottom of this Inkscape help page.

    http://tavmjong.free.fr/INKSCAPE/MANUAL/html/Text-Flow.html