Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Getting double precision floating point accuracy out of QSvgGenerator?
Forum Updated to NodeBB v4.3 + New Features

Getting double precision floating point accuracy out of QSvgGenerator?

Scheduled Pinned Locked Moved Solved General and Desktop
svgqpainter
2 Posts 1 Posters 560 Views
  • 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 Offline
    R Offline
    RobbieP
    wrote on last edited by
    #1

    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
    0
    • R Offline
      R Offline
      RobbieP
      wrote on last edited by
      #2

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

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved