Results 1 to 5 of 5

Thread: svg file gets wrong size

  1. #1
    Join Date
    Oct 2013
    Posts
    18
    Qt products
    Qt4

    Default svg file gets wrong size

    Hi,

    can someone tell if there is a workaround for this svg bug?

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

    Qt Code:
    1. ...
    2. <svg width="wrong value" height="wrong value"
    3. ...
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: svg file gets wrong size

    what are you exporting? and to what you are exporting?

  3. #3
    Join Date
    Oct 2013
    Posts
    18
    Qt products
    Qt4

    Default Re: svg file gets wrong size

    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)

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: svg file gets wrong size

    Define "wrong". What are you expecting to see? Why are you expecting that? What are you actually seeing?

  5. #5
    Join Date
    Oct 2013
    Posts
    18
    Qt products
    Qt4

    Default Re: svg file gets wrong size

    Actually it's the same behaviour as explained in the link in my first post.
    So let's say this is my code:
    Qt Code:
    1. QSvgGenerator generator;
    2. generator.setFileName(file);
    3. generator.setSize(QSize(200, 200));
    4. generator.setViewBox(QRect(0, 0, 200, 200));
    5. generator.setResolution(25.4);//setting the resolution
    6.  
    7. QPainter painter;
    8.  
    9. painter.begin(&generator);
    10. painter.drawRect(10,10,100,100);
    11. painter.end();
    To copy to clipboard, switch view to plain text mode 

    What I get is:
    #without setting resolution I get (first lines of the svg file):
    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    2. <svg width="70.5556mm" height="70.5556mm"
    3. viewBox="0 0 200 200"
    To copy to clipboard, switch view to plain text mode 

    #when setting resolution to 25.4 I get (first lines of the svg file):
    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    2. <svg width="203.2mm" height="203.2mm"
    3. viewBox="0 0 200 200"
    To copy to clipboard, switch view to plain text mode 

    what I would like to get:
    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    2. <svg width="200mm" height="200mm"
    3. viewBox="0 0 200 200"
    To copy to clipboard, switch view to plain text mode 

    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).

Similar Threads

  1. Files added to the wrong .pro file
    By ComServant in forum Newbie
    Replies: 2
    Last Post: 13th February 2013, 18:00
  2. QPrinter, wrong paper size.
    By Sahab in forum Qt Programming
    Replies: 1
    Last Post: 6th February 2012, 21:12
  3. QScrollArea scroll bars wrong size
    By koan in forum Qt Programming
    Replies: 4
    Last Post: 26th November 2010, 14:10
  4. Replies: 3
    Last Post: 29th April 2010, 19:11
  5. QGraphicsView wrong initial size of objects
    By syrtyr in forum Qt Programming
    Replies: 2
    Last Post: 14th July 2009, 07:13

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.