Results 1 to 4 of 4

Thread: Drawing degenerate QCanvasPolygon not working

  1. #1
    Join Date
    Mar 2006
    Posts
    56
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Drawing degenerate QCanvasPolygon not working

    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).

    Qt Code:
    1. class MyPolygon: public QCanvasPolygon
    2. {
    3. ....
    4. void drawShape(QPainter &){...}
    5. };
    To copy to clipboard, switch view to plain text mode 

    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!

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Drawing degenerate QCanvasPolygon not working

    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

  3. #3
    Join Date
    Mar 2006
    Posts
    56
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Drawing degenerate QCanvasPolygon not working

    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.

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Drawing degenerate QCanvasPolygon not working

    Try setting an invisible ( transparency = 1.0 ) stroke for the polygon.

    Regards

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.