PySide - QSvgWidget renders embedded SVG files incorrectly
Question: I try to render embedded svg file using QSvgWidget. My file "front.svg" looks
like this:

    
    
    <svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" width="500" height="500" id="svgfile">
    <rect style="fill:#ff0000;" id="rect1" width="150" height="200"/>
    
    <svg x="100" y="100">
        <rect style="fill:#00ff00;" id="rect2" width="200" height="120"/>
    </svg>
    </svg>
    

This file looks quite normal in Chrome, or Inkscape, but in svgwidget it looks
strange. Only green rectangle is visible, and red is very small, and hidden
behind the green one. Here is my python code:

    
    
    import sys
    from PySide.QtGui import QApplication
    from PySide.QtSvg import QSvgWidget
    
    if __name__ == '__main__':
        app = QApplication(sys.argv)
    
        widget = QSvgWidget('front.svg')
        widget.show()
    
        sys.exit(app.exec_())
    

Does anybody knows, whether I do something wrong, or is it some bug in PySide?


Answer: You can get it to render correctly by removing the extra internal `<svg>` tag,
and moving the x and y attributes to the `<rect>` element:

    
    
    <svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" width="500" height="500" id="svgfile">
    <rect style="fill:#ff0000;" id="rect1" width="150" height="200"/>
    <rect style="fill:#00ff00;" id="rect2" x="100" y="100" width="200" height="120"/>
    </svg>
    

I assume this is a contrived example to test that specific case, though? Is
there a reason you need nested `<svg>` elements?

