Hi All,

I have developed a qwt that contains multiple QwtPlotShapeItems.

Qt Code:
  1. //Run a function to get an array of polygons
  2. QVector<QPolygonF> polygonArray;
  3. createPolygonArray(lines, polygonArray, maxdistance);
  4.  
  5. //add each polygon in the polygon array to the qwt plot
  6. for (int j = 0; j < polygonArray.size(); j = j + 1)
  7. {
  8. QwtPlotShapeItem *shape = new QwtPlotShapeItem;
  9. shape->setPen(QColor(0,0,0), Qt::SolidLine);
  10. shape->setTitle("shapeNumber_" + QString::number(j));
  11. shape->setBrush(QColor(130,130,130,50));
  12. shape->setPolygon(polygonArray[j]);
  13. shape->attach(&myPlot);
  14. V.push_back(shape);
  15. }
  16. myPlot.replot();
To copy to clipboard, switch view to plain text mode 

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:

Qt Code:
  1. //.....later on in my code, in another function that the plot is passed into (by ref)
  2. for (int j = 0; j < myPlot.numberOfAttachedShapeItems(); j = j + 1)
  3. {
  4. if (myPlot.attachedShapeItem[j].Title() == "shapeNumber_7")
  5. {
  6. myPlot.attachedShapeItem[j].setBrush(QColor(0,0,0,255));
  7. }
  8. }
To copy to clipboard, switch view to plain text mode 

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!