Tryst Tryst - 7 months ago 50
Python Question

PySide Error - QPaintDevice: Cannot destroy paint device that is being painted

I'm baffled by this one. I tried moving the

QPainter
to it's own
def
as some have suggested, but it gives the exact same error. Here's the
def
I created.

def PaintButtons(self):
solid = QtGui.QPixmap(200, 32)
paint = QtGui.QPainter()
paint.begin(solid)
paint.setPen(QtGui.Qcolor(255,255,255))
paint.setBrush(QtGui.QColor(255, 0, 0))
paint.drawRect(0, 0, 200, 32)
paint.end()

Answer

It was just a typo. You're using Qcolor (the first occurrence).
Changing that to QColor will do the trick. :)

Comments