PDA

View Full Version : Removing and Redrawing Lines in a QGraphicsScene in PyQT



giverson
26th February 2007, 18:23
I've run into a few bugs that I've run into in Qt/PyQt that I can devise a workaround for but this one has got me stumped.

I'm currently using Python 2.5 and the latest version of PyQT.

What I've been trying to do is draw polygons with a background on a scene, remove all lines, and draw new lines on top of those polygons, rinse, and repeat. The polygon remains static...only the lines drawn on top change.

When I don't set background colors on the polygons, this process works fine. However, when I put a background color on any of my polygons, random lines will refuse to show through the background of those polygons. The end result being anywhere from 0-100% of my lines actually showing when I clear and redraw these lines.

I haven't translated this program over to C++/QT so I'm not sure where exactly this bug lies.

It seems there's a problem with the priority of it drawing the background on the polygons or if it's a first come first draw draw process, it's randomly adding my newly added lines below the polygon.

I'm really just looking for possible workarounds short of fully recreating my scene (the real program draws anywhere from 1k - 9k polygons (up to about 20 megs worth of points) depending on the scene.

The Sample Program:
This program uses unsupported behavior in it's switching scenes. I could've included extra code to handle "bugs" associated with this behavior but it's easier for me just to tell you that to initially switch the scene, you'll need to load the scene twice before it will change. This is a weird behavior but it's not the cause of my problem. This redraw bug will occur even if the only actions you take are removing the lines and drawing new ones. In fact, I only use multiple scenes in this test program because it's the easiest way to test.

To see the redraw effect, press F1 or F2 over and over again. F1 is a working version without color and F2 is a broken version with color.

giverson
26th February 2007, 21:23
We got a version of this running in C++/QT and confirmed that the problem still occurs.

I'll try to post that modified code later.

There was a few minor things in the python code but nothing that caused the problem. I did a 10 minute copy/paste/delete job on it so I missed a few things...:rolleyes: