Getting double precision floating point accuracy out of QSvgGenerator?
-
wrote on 28 Aug 2020, 15:34 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?
-
wrote on 28 Aug 2020, 15:46 last edited by
Solved it by changing my drawline to: painter.drawLine(QPointF(pX1, pY1), QPointF(pX2, pY2));
2/2