Multiline text text in svg displayed in qt

I am trying to create an svg that will read in QGraphicsSvgItem. I read some documentation and it seems like this is what I want:

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 43363)  -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     width="100px" height="100px" viewBox="0 0 100 100" enable-background="new 0 0 100 100"
     xml:space="preserve">
    <rect fill="#437624" stroke="none" fill-opacity="1" x="0" y="0" width="100" height="100" />

    <text y="50" transform="translate(50)">
       <tspan x="0" text-anchor="middle">No</tspan>
       <tspan x="0" text-anchor="middle" dy="15">Arrow</tspan>
   </text>
</svg>

This creates a rectangle - and multi-line text with the center inside:
enter image description hereThis is what the browser looks like.

In Qt, however, when loaded in, QGraphicsSvgItemit looks like this:
enter image description here

I assume something is not supported by the Qt SVG renderer ...

Even worse, if I set the font size, my Qt text will completely disappear:

    <text y="40" font-size="24" transform="translate(50)">
       <tspan x="0" text-anchor="middle">No</tspan>
       <tspan x="0" text-anchor="middle" dy="30">Arrow</tspan>
   </text>

How can I get Qt to get text with several lines in the center, like the first image, from svg (what should I add to SVG)?

(Qt from 4.7 to 5.5 ...)

Edit:

This worked (but still can't figure out how to make multi-line strings other than defining individual elements)

<text x="0" y="40" font-size="24" transform="translate(50)" text-anchor="middle">No</text>
<text x="0" y="70" font-size="24" transform="translate(50)" text-anchor="middle">Arrow</text>

, svgs , svgs, tspan, , QGraphicsSvgItem - , , , .

+4
1

, QGraphicsSvg SVG Tiny 1.2.

SVG Tiny, SVG, SVG Tiny "tspan", :

" , " x "," y "" rotate ", " tspan " SVG Tiny 1.2."

. SVG Tiny 1.2: https://www.w3.org/TR/SVGTiny12/text.html#TSpanElement

. QT svg?

+2

All Articles