PDA

View Full Version : svg file gets wrong size



qtbeginner0
23rd November 2013, 15:42
Hi,

can someone tell if there is a workaround for this svg bug (https://bugreports.qt-project.org/browse/QTBUG-2427)?

The problem is when exporting to svg the width and height properties/attributes are wrong.


...
<svg width="wrong value" height="wrong value"
...

saman_artorious
23rd November 2013, 21:18
what are you exporting? and to what you are exporting?

qtbeginner0
23rd November 2013, 22:54
I'm drawing things using QSvgGenerator as the paint device for QPainter.
And drawing things, using something like QPainter::drawPolyline... .
(saving the drawing as .svg file)

ChrisW67
24th November 2013, 12:25
Define "wrong". What are you expecting to see? Why are you expecting that? What are you actually seeing?

qtbeginner0
25th November 2013, 23:37
Actually it's the same behaviour as explained in the link in my first post.
So let's say this is my code:

QSvgGenerator generator;
generator.setFileName(file);
generator.setSize(QSize(200, 200));
generator.setViewBox(QRect(0, 0, 200, 200));
generator.setResolution(25.4);//setting the resolution

QPainter painter;

painter.begin(&generator);
painter.drawRect(10,10,100,100);
painter.end();

What I get is:
#without setting resolution I get (first lines of the svg file):

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="70.5556mm" height="70.5556mm"
viewBox="0 0 200 200"

#when setting resolution to 25.4 I get (first lines of the svg file):

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="203.2mm" height="203.2mm"
viewBox="0 0 200 200"

what I would like to get:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="200mm" height="200mm"
viewBox="0 0 200 200"

As I define the size as 200,200 I would also like to get a 200mm,200mm drawing (so my rectangle has the correct size of 100mm,100mm).