Quantcast
Channel: Active questions tagged qpainter - Stack Overflow
Viewing all articles
Browse latest Browse all 58

PIL Image to PixMap Error on QImage Conversion

$
0
0

The following code block:

class MDraw(QtWidgets.QGraphicsView):    def __init__(self, parent):        super(MDraw, self).__init__(parent)        self.data = None        self.width = 0        self.height = 0    def resizeEvent(self, event):        self.width = event.size().width()        self.height = event.size().height()        self.draw(self.data)    def draw(self, indata):        self.image = QImage(self.width, self.height, QImage.Format_ARGB32)        self.image = QImage(self.width, self.height, QImage.Format_Grayscale8)        self.image = QImage(self.width, self.height, QImage.Format_Alpha8)        self.image = QImage(self.width, self.height, QImage.Format_RGB32)        qpainter = QPainter(self.image)        bbush = QBrush(QColor(90,0,0))        qpainter.setBrush(bbush)        qpainter.drawRect(20, 20, 80, 80)        qpainter.end()        self.pixmap = QPixmap.fromImage(self.image)        self.pixmapItem = QGraphicsPixmapItem(self.pixmap)        scene = QGraphicsScene()        scene.addItem(self.pixmapItem)        self.setScene(scene)

Works fine when expanding the widget size, but produces artifacts when shrinking?

enter image description here


Viewing all articles
Browse latest Browse all 58

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>