Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Solved Getting double precision floating point accuracy out of QSvgGenerator?

    General and Desktop
    svg qpainter
    1
    2
    227
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      RobbieP last edited by

      I'm using QPainter and QSvgGenerator to generate a set of symbologies that I need vector accuracy on. I have a series of controls to set up the generation of the shapes and I'm drawing them using QPainter. My ultimate goal is a mathematically accurate SVG vector image, but I only seem to be getting pixel level accuracy from QPainter to SVG Generator. When I calculate the positions of my lines, I'm not sure if QPainter is rounding to the nearest whole pixel position, but I'm drawing the symbology in a 512x512 widget space. This of course gives me a 512x512 pixel svg, with the lines snapped to the nearest pixel instead of the actual double precision floating point x/y values I calculated...

      If I want an accurate Vector image, should I just dump all of my points into a buffer and write my own SVG generator or is there a way to get double precision vector accuracy with QPainter to SVG Generator with a display size of only 512x512?

      I did notice that all of the QPainter drawline functions take int's not doubles for points...That's my problem for sure...what's a better way to render to SVG with higher accuracy?

      1 Reply Last reply Reply Quote 0
      • R
        RobbieP last edited by

        Solved it by changing my drawline to: painter.drawLine(QPointF(pX1, pY1), QPointF(pX2, pY2));

        1 Reply Last reply Reply Quote 1
        • First post
          Last post