PDA

View Full Version : QRegion from QPolygon border issue



jorenheit
29th May 2012, 16:08
Hello,

I'm developing a little game that uses QPolygons as game-elements. These polygons may change position on the screen (it's a board-game), thus paintEvent is called whenever this happens. Since a QPolygon can be promoted to a QRegion through one of QRegions constructors, it is possible to pass the polygon that needs updating to the QWidget::update() function in order to only update this area and avoid redrawing the entire screen. However, on constructing a QRegion from a QPolygon, it seems that only the inside of the QPolygon is taken in account. For example, when removing such a polygon from the screen (i.e. redrawing the background), some of the border of the polygon (a black edge) remains! Does anyone have a suggestion on how to fix this?
I considered redrawing the entire boundingRect() of the polygon, but this brings a lot of inconveniences along with it...

Cheers,

Joren

Spitfire
31st May 2012, 16:18
I'm guessing you have to account for pen width used to draw that polygon but I'm not sure how you would do that.