Problems with Open-Source Downloads read and

Change colour of specific item in Qwt Plot

  • Hi All,

    I have developed a qwt that contains multiple QwtPlotShapeItems.

    //Run a function to get an array of polygons
    QVector<QPolygonF> polygonArray;
    createPolygonArray(lines, polygonArray, maxdistance);
    //add each polygon in the polygon array to the qwt plot
    for (int j = 0; j < polygonArray.size(); j = j + 1)
        QwtPlotShapeItem *shape = new QwtPlotShapeItem;
        shape->setPen(QColor(0,0,0), Qt::SolidLine);
        shape->setTitle("shapeNumber_" + QString::number(j));

    I want to return to my plot at a later point in my code and loop through all the attached QwtPlotShapeItems, and if it's title matches what I looking for, then I want to change the colour of that shape. So for example:

    //.....later on in my code, in another function that the plot is passed into (by ref)
    for (int j = 0; j < myPlot.numberOfAttachedShapeItems(); j = j + 1)
        if (myPlot.attachedShapeItem[j].Title() == "shapeNumber_7")

    Is this possible, or do I have to recreate my plot each time I want to change the color of a single shapeItem?

    Thank you!

Log in to reply