I want to use pyqt5 to draw some simple vectorial images using Python.
So far, I've managed to generate an image with the following code:
import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
class MyPainter(QImage):
def __init__(self):
super().__init__(400, 400, QImage.Format_RGB32)
self.fill(Qt.black)
painter = QPainter(self)
painter.setPen(QPen(Qt.red, 8))
painter.drawRect(40, 40, 200, 100)
if __name__ == "__main__":
app = QApplication(sys.argv)
w = MyPainter()
w.save('test.png', 'PNG')
Which draws the following image:
I want to do the same thing but rendering a SVG.
Is it possible with pyqt5.qtsvg module? How would it be inserted in the code above? I just can't find any example.