Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
4.7.4, 5.5.1
-
None
-
Windows
Description
Saving a QGraphicsScene to an Svg generates an Svg that is 1.25 times bigger than the source; The ViewBox is smaller (80%) which, in a QGraphicsSvgItem that creates a boundingRect based on its size, smears while moving.
Also, trying to scale my source by 80% before saving to svg was almost ok - but due to converting the size to metric, an original content of 100x100 scaled by .8 becomes an svg of size 99x99, and when re-generated, 98x98 and so on... Why is it converted to metric instead of keeping the default units ? Due to the setSize function only accepting integers, it is impossible to ever get an accurate size, so re-using the generated svg will end up getting smaller each time...
Even more fun, if the generated svg is added to a QGraphicsScene, which is saved to a svg, the new svg (other than just growing bigger) also gets added outlines around all items (even if initially they had no pen) and around the svg itself. This particular "feature" I only noticed in Qt 4 (4.7), was missing in Qt 5 (5.5), and I believe it is due to the reinterpreting of the "stroke-linecap=\"square\" " added for each entry in generateQtDefaults().
One more thing... If an item is clipped / partially shown on scene due to clipping, saving to svg shows the entire item. Example: a QGraphicsTextItem with text content that does not fit in its bounding rectangle. The saved svg will still show the entire text, even though on the scene the text is clipped.
I have tested this, not just with my own code but with the svggenerator project from the examples.