I want to draw some triangles in my widget pointing up: ie. two vertices are on the same horizontal line and a third vertex halfway between these two points and above.

When the triangle is not filled the top vertex is "sharp" but when I draw the triangle filled, it does not have a "sharp" point: an extra diagonal line of pixels is added on the left side, outside of the triangle.

Qt Code:
  1. void widget::paintEvent(QPaintEvent *)
  2. {
  3. QPainter p(this);
  4.  
  5. p.setPen(Qt::black);
  6. p.setBrush(Qt::black);
  7.  
  8. int halfwidth = 7;
  9. int height = 7;
  10.  
  11. QPolygon triangle;
  12.  
  13. triangle.clear();
  14. triangle << QPoint(10+halfwidth, 10-height);
  15. triangle << QPoint(10, 10);
  16. triangle << QPoint(10+2*halfwidth, 10);
  17. p.drawPolygon(triangle);
  18. }
To copy to clipboard, switch view to plain text mode 

unfill-vs-fill-zoom.png

Note: The image in the preview for this post doesn't look right: click through to see the attachment properly