为什么使用简单的QPixMap和绘图命令显示我的图像会损坏。它每隔一段时间就会正确地显示。
self._pixmap = QtGui.QPixmap(128,128)
painter = QtGui.QPainter(self._pixmap)
brush = QtGui.QBrush(QtCore.Qt.SolidPattern)
brush.setColor(QtGui.QColor(240, 20, 20, 255))
painter.setPen(QtGui.QPen(brush, 1, QtCore.Qt.SolidLine,QtCore.Qt.SquareCap))
painter.drawLine(0, 0, self._pixmap.width(), self._pixmap.height())
painter.drawLine(self._pixmap.width(), 0, 0, self._pixmap.height())
painter.end()

发布于 2018-06-12 15:22:40
您应该在使用fill进行绘图之前调用QPainter,查看有关QPixmap构造函数的参考这里。
这将创建一个具有未初始化数据的PySide.QtGui.QPixmap。调用PySide.QtGui.QPixmap.fill(),在使用PySide.QtGui.QPainter绘图之前,用适当的颜色填充像素映射。
https://stackoverflow.com/questions/50820545
复制相似问题