Problems with Open-Source Downloads read https://www.qt.io/blog/problem-with-open-source-downloads and https://forum.qt.io/post/638946
Stroke width vector-effect="non-scaling-stroke" in generated SVG: problem is usually the SVG viewer
bootchk last edited by
This describes a problem/solution about stroke-width scaling in SVG generated by Qt. Qt sometimes generates the SVG property vector-effect="non-scaling-stroke" . Not all SVG viewers properly display this SVG generated by Qt . Recent viewers such as Firefox are proper, older viewers such as Image Viewer and Inkscape on Ubuntu are not proper.
In this code, the two graphics items render properly in a QGraphicsView (to the display). In rendered svg, the stroke width of the second is huge, DEPENDING ON THE SVG VIEWER.
The first item is created by the convenience function addRect(), and displays properly in older SVG viewers.
The second item is a unit rect, scaled, and displays properly only in recent SVG viewers.
In older viewers, it displays with a huge stroke-width and looks liked a filled rect with mangled corners.
# Non-unit rect
self.addRect(10, 10, 20, 20, pen=QPen(Qt.red))
# Scaled unit rect item = QGraphicsRectItem(0,0,1,1) item.setPos(30,30) item.setScale(20) self.addItem(item)@
The "problem" then is one with conformance to the SVG standard.