Hello,

I'm trying to draw some colored rectangles with PyQt.
I have created the following class:

class MappyZone(QGraphicsItem):
    def __init__(self, x1, y1, x2, y2, color):
        super(MappyZone, self).__init__()
        self.rect = QRectF(x1, y1, x2 - x1, y2 - y1)
        self.color = color

    def boundingRect(self):
        return self.rect

    def paint(self, painter, option, widget=None):
        painter.setPen(Qt.NoPen)
        painter.setBrush(QBrush(self.color))
        painter.drawRect(self.rect)
    pass

My problem starts when 2 zones are overlapping. In this case,
the intersected part of the two QRectF can appear in one color
or the other althought I add these 2 zones always in the same order
to the scene  with:
self.scene.addItem(zone)
zone is a MappyZone() and scene is a QGraphicsScene().

Moreover, this behavior (bug?) is appearing only on the Linux OS  (tested on
Ubuntu, Debian and Scientific Linux) but it never happens on Windows 7.
On Windows, the second rectangle is always drawn on
top of the first rectangle.

Could someone help me to understand what is happening?

Regards,
Marc.
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to