[PyQt] Problem with colored rectangles

shi dingan shi.dingan at gmail.com
Sun Feb 20 00:59:54 GMT 2011


Ok, it works on my simple test case.
I did not know the setZValue method.
Now I'll use it in my "real" application.

Thx a lot,
Marc.

2011/2/20 David Boddie <david at boddie.org.uk>

> On Sat Feb 19 22:22:10 GMT 2011, shi dingan wrote:
>
> > I have a problem with my code when I try to draw two rectangles with
> > overlap.
> > I draw a red one, then a green with a small part of it overlapping the
> red
> > rectangle.
> > But when I refresh the scene, I have a random behavior, that is,
> sometimes
> > only the red rectangle appears and sometimes both rectangle appear.
> > Is it a normal behavior?
>
> Really, both should appear. I think the confusion arises because the green
> one lies within the space occupied by the red one.
>
> > I was expecting to see always both rectangle since the
> > red one is always the first one added to the scene...
>
> Sometimes the red one appears on top of the green one. Because it covers
> the same area as the green rectangle, it looks like only the red rectangle
> is added to the scene. To make the green rectangle appear on top, set a
> Z value for each of them, but make sure the green rectangle has a higher
> value than the red, like this:
>
>  zone1.setZValue(0)
>  zone2.setZValue(1)
>
> David
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110220/a49c5890/attachment.html>


More information about the PyQt mailing list