
Originally Posted by
Uwe
Changing the brush only is fine.
Uwe
I cant find how to change the fill colour of the plotitem. Could you see what I missing? Thank you for your help!
QwtPlotItemList plotItemList = myPlot.itemList();
for (int m = 0; m < plotItemList.size(); m = m + 1)
{
if(plotItemList
[m
]->title
().
text() == QString::fromStdString(desiredName
[i
])) {
plotItemList[m]-> //??? there is no setBrush to use here....I would expect to write...setBrush(QColor(0,0,0,255));
}
else
{
plotItemList[m]-> //??? there is no setBrush to use here....I would expect to write...setBrush(QColor(130,130,130,50));
}
}
QwtPlotItemList plotItemList = myPlot.itemList();
for (int m = 0; m < plotItemList.size(); m = m + 1)
{
if(plotItemList[m]->title().text() == QString::fromStdString(desiredName[i]))
{
plotItemList[m]-> //??? there is no setBrush to use here....I would expect to write...setBrush(QColor(0,0,0,255));
}
else
{
plotItemList[m]-> //??? there is no setBrush to use here....I would expect to write...setBrush(QColor(130,130,130,50));
}
}
To copy to clipboard, switch view to plain text mode
Added after 30 minutes:

Originally Posted by
Uwe
Changing the brush only is fine.
Uwe
I managed to work out how to do it
Here is what I did (I found some code online that had your name on it which guided me to the right solution).
QwtPlotItemList plotItemList
= myPlot.
itemList(QwtPlotItem::Rtti_PlotShape /*added this*/);
for (int m = 0; m < plotItemList.size(); m = m + 1)
{
QwtPlotShapeItem *shape = static_cast<QwtPlotShapeItem *>( plotItemList[m] ); //added this line
if(plotItemList
[m
]->title
().
text() == QString::fromStdString(desiredName
[i
])) {
shape
->setBrush
(QColor(0,
0,
0,
255));
//now can set brush to the shape directly }
else
{
shape
->setBrush
(QColor(130,
130,
130,
50));
//now can set brush to the shape directly }
}
QwtPlotItemList plotItemList = myPlot.itemList(QwtPlotItem::Rtti_PlotShape /*added this*/);
for (int m = 0; m < plotItemList.size(); m = m + 1)
{
QwtPlotShapeItem *shape = static_cast<QwtPlotShapeItem *>( plotItemList[m] ); //added this line
if(plotItemList[m]->title().text() == QString::fromStdString(desiredName[i]))
{
shape->setBrush(QColor(0,0,0,255)); //now can set brush to the shape directly
}
else
{
shape->setBrush(QColor(130,130,130,50)); //now can set brush to the shape directly
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks