Hello,<br><br>I'm trying to draw some colored rectangles with PyQt.<br>I have created the following class:<br><br>class MappyZone(QGraphicsItem):<br> def __init__(self, x1, y1, x2, y2, color):<br> super(MappyZone, self).__init__()<br>
self.rect = QRectF(x1, y1, x2 - x1, y2 - y1)<br> self.color = color<br><br> def boundingRect(self):<br> return self.rect<br><br> def paint(self, painter, option, widget=None):<br> painter.setPen(Qt.NoPen)<br>
painter.setBrush(QBrush(self.color))<br> painter.drawRect(self.rect)<br> pass<br><br>My problem starts when 2 zones are overlapping. In this case,<br>the intersected part of the two QRectF can appear in one color<br>
or the other althought I add these 2 zones always in the same order<br>to the scene with:<br>self.scene.addItem(zone)<br>zone is a MappyZone() and scene is a QGraphicsScene().<br><br>Moreover, this behavior (bug?) is appearing only on the Linux OS (tested on<br>
Ubuntu, Debian and Scientific Linux) but it never happens on Windows 7.<br>On Windows, the second rectangle is always drawn on<br>top of the first rectangle.<br><br>Could someone help me to understand what is happening?<br>
<br>Regards,<br>Marc.<br>