I’m struggling with using the QGraphicsItem paint method to use a qpixmap as cache on which I draw a path and at the end of paint method I use painter.drawPixmap(cache_pixmap)
but I get weird rendering
it doesn’t show the lines I drawn on the qpixmap using drawPath.
def paint(self, p, opt, widget):
self.cachePixmap = QPixmap(1000, 100)
self.cachePixmap.fill(QtGui.QColor('black')) # Fill with black background
# Ensure there's data to paint
if self.xData is None or len(self.xData) == 0 or self.x_data is None:
return
aa = self.opts['antialias']
cache_painter = QtGui.QPainter(self.cachePixmap)
cache_painter.setRenderHint(QtGui.QPainter.RenderHint.Antialiasing, aa)
for start, end, color in self.ranges:
if color == 0:
continue
if start > 0:
start -= 1
path = arrayToQPath(self.x_data[start:end], self.y_data[start:end], connect='all', finiteCheck=False)
pen = QPen(QColor('white'))
pen.setWidth(1)
cache_painter.setPen(pen)
cache_painter.drawPath(path)
cache_painter.end()
p.drawPixmap(self.boundingRect(), self.cachePixmap, QRect(0, 0, 1000, 100))
def boundingRect(self):
if self._boundingRect is None:
self._boundingRect = self.viewRect()
return self._boundingRect
this code is an overwritten paint method of QGraphicsItem
when I draw directly to p the path (is a curve) shows up, but when I use QPixma, the rendering is weird like in this picture
actually I’m overwritten pyqtgraph PlotCurveItem which itself inherits from QGraphicsItem paint method
I’m really stuck with this, any help would be appreciated, thank uuuuu
PS: this what I get when I use drawPixmap