PDA

View Full Version : Drawing degenerate QCanvasPolygon not working



kalos80
27th June 2007, 11:40
Hi there,

I have subclassed the QCanvasPolygon class and reimplemented the drawShape function in order to draw polygons with outlines (QCanvasPolygon class doesn't allows outlines for polygons).



class MyPolygon: public QCanvasPolygon
{
....
void drawShape(QPainter &){...}
};


The drawShape in MyPolygon is working and I can see an outline for polygons that are in the canvas view.

The problem is that if a polygon is degenerate, that is if all verteces of the polygon are on a straight line (this implies that the area of the polygon is null), the drawShape of the polygon is not called when I update the canvas, so the polygon is not drawn.

Thanks in advance for your help!

marcel
27th June 2007, 22:02
Why didn't you create a custom pen for the outline and then set it with setPen?
The degenerate item isn't painted because Qt thinks it has nothing to draw.

Regards

kalos80
28th June 2007, 08:09
Is there a way to force the Qt to draw the item also if it is a degenerate polygon?

I had a look to the QCanvas code but I didn't find any clue.

marcel
28th June 2007, 10:52
Try setting an invisible ( transparency = 1.0 ) stroke for the polygon.

Regards