Issue with QPolygonF and QGraphicsPolygonItem (brought a picture)



  • Hello,

    Picture

    I seem to be having this unwanted black segment when drawing triangles. Here's what I did with the QPolygonF:

    qreal root = qSqrt(3)/2;
    
    QPolygonF DownwardTriangle = QPolygonF(3);
    DownwardTriangle << QPointF(root, .5)*80 << QPointF(-root, .5)*80 << QPointF(0, -1)*80 << QPointF(root, .5)*80;
    

    and here's how I added it to the QGraphicsScene:

    auto foo = WindowScene.addPolygon(DownwardTriangle, QPen(), GrayBrush);
    foo->setPos(100, 100);
    

    I tried both fillRules but I got the black segment (from the top-right corner to the center of the triangle) in both cases regardless. I can't get rid of it. The top-right corner matches the first and last QPointF that I stored inside DownwardTriangle (which is QPointF(root, .5)*80).

    Any help would be appreciated. Thank you.



  • Hi

    U have a garbage points.

    QPolygonF DownwardTriangle = QPolygonF(3);
    <-- U must delete "QPolygonF(3)"



  • @Devopia53

    Thank you! The problem disappears if I drop the = QPolygonF(3); :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.