Nominate our 2022 Qt Champions!

QGraphicsSvgitem don't display svg with pattern

  • Hello,

    i have a problem with an svg File which includes a pattern.
    The QGraphicsSvgItem works very nice without pattern but if i use a svg file with pattern it will not be shown. Why?

    The svg File:
    <?xml version="1.0" standalone="no"?>
    <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
    <svg width="100" height="100" viewBox="0 0 100 100"
    xmlns="" version="1.1">
    <desc>Example rect01 - rectangle with sharp corners</desc>

    <pattern id="pattern1" x="0" y="0" width="5" height="5" patternUnits="userSpaceOnUse" >
    <line x1="0" y1="0" x2="5" y2="5" style="stroke:rgb(0,0,0);stroke-width:0.5" />
    <line x1="0" y1="5" x2="5" y2="0" style="stroke:rgb(0,0,0);stroke-width:0.5" />
    <rect x="0" y="0" width="100" height="100" style="fill: url(#pattern1)" />

  • Ok,
    i found that Qt implements the static elements of SVG Tiny 1.2.
    I found this from the year 2006. Has that changed ?

    Is there a other way to tile(fill) the given rect?
    Or I must fill it myself?

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    The latest state of SVG support is described here AFAIK if you need a full blown SVG renderer then you'd need e.g. QtWebKit