私はこのコードを持っています:
def paintEvent(self, paintEvent):
self._painter.begin(self)
try:
while True:
color, rectangle = self._paint_queue.popleft()
self._painter.fillRect(rectangle, color)
except IndexError:
pass
finally:
self._painter.end()
def drawInstruction(self, ptr, instruction):
rectangle = QtCore.QRect(
(ptr % self.cols)*CELL_SIZE,
math.floor(ptr/float(self.cols))*CELL_SIZE,
CELL_SIZE,
CELL_SIZE)
self._paint_queue.append((opcode2color[instruction.opcode],
rectangle))
self.update()
そして、drawInstruction()を呼び出すたびに、すでに描画されているものはすべてクリアされます。新しい長方形だけが残ります。
また、drawInstruction()は頻繁に呼び出されるため、drawInstruction()を呼び出すたびにすべてを再描画することは解決策ではありません。