0

I have a big svg(70000 * 2000) and I want to display it completely. I Used QPixmap and I found it was incomplete. This is my code:

self.img = QPixmap('test.svg')
self.scaled_img = self.img

def paintEvent(self, e):
    painter = QPainter()
    painter.begin(self)
    self.draw_img(painter)
    painter.end()

def draw_img(self, painter):
    painter.drawPixmap(self.point, self.scaled_img)

1 Answers1

0

According to the QPainter documentation:

If you are using coordinates with Qt's raster-based paint engine, it is important to note that, while coordinates greater than +/- 215 can be used, any painting performed with coordinates outside this range is not guaranteed to be shown; the drawing may be clipped.

This seems to be a limitation valid for QImage and QPixmap too, as explained in the answer to QImage/QPixmap size limitations?, which means that the image will only be rendered up to 32767x32767.

You may want to try using QSvgRenderer.render(painter, rect) in order to scale it, or setViewBox() and then the basic render() to show portions of it.

musicamante
  • 41,230
  • 6
  • 33
  • 58