Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[SOLVED] Polygon with holes fading



  • I have managed to get a polygon with holes appearing. However the holes get darker and darker for some reason?

    Here is an example...

    !http://www.streettrack.co.uk/polygonhole.jpg(Example of polygon hold)!

    Here is the code:

    @
    QPainterPath path;
    path.addPolygon(poly); // Outer region.
    if (v_polyinner.size() > 0)
    {
    QPainterPath inner;
    for (int iPoly = 0; iPoly < v_polyinner.size(); iPoly++)
    {
    inner.addPolygon(v_polyinner[iPoly]);
    }
    path = path.subtracted(inner);
    }

    stringstream sscolour;
    sscolour << "#" << polyi->getColour();
    QColor colour(QString::fromStdString(sscolour.str()));
    colour.setAlpha(127);
    QBrush brush(colour);
    painter.setBrush(brush);
    if (this->sSelectedItemGUID == polyi->getFeatureGUID()) painter.setPen(penHighlight);
    painter.fillPath(path, brush);
    @

    It's seems as though as each polygon is added is goes darker.



  • Whoops, made a mistake loading the coordinates, so multiple polys were on top of each other and gradually fading the holes out.


Log in to reply