so i want to change the color of an QGraphicsSvgItem in a QGraphicsScene. I have this little code snippet:
from PyQt5 import (QtWidgets as qtw, QtCore as qtc, QtGui as qtg, QtSvg as qsvg)
class HitIcon(qsvg.QGraphicsSvgItem):
def __init__(self, field):
super(HitIcon, self).__init__('my.svg'))
self.setScale(.3)
self._brush = qtg.QBrush(qtc.Qt.red)
self.update()
def paint(self, painter=None, Style=None, widget=None):
painter.fillRect(self.boundingRect(), self._brush)
This fills the complete boundingRect of the svgitem with the specified color. I searched the documentation of QPainter to find a way to only fill the svg path but couldn't find anything.
i also tried the following:
painter.fillPath(self.clipPath(), self._brush)
painter.fillRect(self.clipPath(), self._brush)