QPainter/QPainterPath and svg groups



  • I am sure this has been discussed before but I can't seem to find anything on it.

    I am using QPainter and QPainterPath to generate path information that I output to an svg file. This works fine except when I want to have nested groups. I can't seem to find the correct combination of commands to allow me to nest grouped paths.

    Below was generated with SVG-edit and is a simple example of what I am trying do.

    @<svg width="640" height="480" >
    <!-- Created with SVG-edit - http://svg-edit.googlecode.com/ -->
    <g>
    <title>Layer 1</title>
    <g id="svg_9">
    <g id="svg_7">
    <g id="svg_3">
    <rect id="svg_1" height="63" width="75" y="38" x="39" stroke-width="5" stroke="#000000" fill="#FF0000"/>
    <rect id="svg_2" height="74" width="121" y="155" x="62" stroke-width="5" stroke="#000000" fill="#FF0000"/>
    </g>
    <g id="svg_6">
    <ellipse ry="44" rx="44" id="svg_4" cy="77" cx="312" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="5" stroke="#000000" fill="#FF0000"/>
    <ellipse ry="31" rx="29" id="svg_5" cy="165" cx="301" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="5" stroke="#000000" fill="#FF0000"/>
    </g>
    </g>
    <circle id="svg_8" r="44.65423" cy="320" cx="199" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="5" stroke="#000000" fill="#FF0000"/>
    </g>
    </g>
    </svg>@

    Using the Qt classes, I get something similar to the following where all my grouped paths are at the same level (this isn't exact since I don't have Qt loaded on this system):

    @<svg width="640" height="480" >
    <g>
    <title>Layer 1</title>
    <g>
    <rect id="svg_1" height="63" width="75" y="38" x="39" stroke-width="5" stroke="#000000" fill="#FF0000"/>
    <rect id="svg_2" height="74" width="121" y="155" x="62" stroke-width="5" stroke="#000000" fill="#FF0000"/>
    </g>
    <g>
    <ellipse ry="44" rx="44" id="svg_4" cy="77" cx="312" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="5" stroke="#000000" fill="#FF0000"/>
    <ellipse ry="31" rx="29" id="svg_5" cy="165" cx="301" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="5" stroke="#000000" fill="#FF0000"/>
    </g>
    <g>
    <circle id="svg_8" r="44.65423" cy="320" cx="199" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="5" stroke="#000000" fill="#FF0000"/>
    </g>
    </g>
    </svg>@

    Any suggestions are appreciated. Thanks.



  • No ideas?

    Guess I can drop the use of the QPainter/QPainterPath classes and just manually create the svg file. Bit more work but does give me more control.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.