Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python QPixmap损坏的图像_Python_Pyside - Fatal编程技术网

Python QPixmap损坏的图像

Python QPixmap损坏的图像,python,pyside,Python,Pyside,为什么我的图像在使用简单的QPixMap和draw命令显示时会损坏。每隔一段时间它就会正确显示 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,

为什么我的图像在使用简单的QPixMap和draw命令显示时会损坏。每隔一段时间它就会正确显示

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()
您应该在使用QPainter绘制之前调用fill,请参阅关于QPixmap构造函数的参考资料

这将使用未初始化的数据创建PySide.QtGui.QPixmap。调用PySide.QtGui.QPixmap.fill以在使用PySide.QtGui.QPainter绘制pixmap之前使用适当的颜色填充该pixmap


这就是你记忆中的内容。你得到的印象是未定义的行为。声明!=初始化。你只是在声明。fillcolor初始化您的QPixmap。