PDA

View Full Version : Dynamically change existing curve color



missoni
19th June 2012, 09:26
Hey guys,
I try to dynamically change colors of curves in my Qwt plot depending on user interaction, but I can't figure out how I can force QwtPlot to repaint all curves with new colors. This is the code I use for giving my curves their initial color:


Curve::Curve(QColor color) {
QBrush brush;
brush.setColor(color);
brush.setStyle(Qt::SolidPattern);
QPen pen(brush,2,Qt::SolidLine);
this->setPen(pen);
QColor bgColor = color;
bgColor.setAlphaF(0.3f);
brush.setColor(bgColor);
this->setBrush(brush);
this->setRenderHint(QwtPlotItem::RenderAntialiased);
}
where Curve publicly derives from QwtPlotIntervalCurve.

I similar Curve::setColor(QColor color) function does not have any impact if I call it after I attach the curve to the plot. Detaching and re-attaching of the curve does not have any impact either. Any ideas how I can dynamically change the color of existing curves?

Thank you in advance!

Uwe
19th June 2012, 09:43
QwtPlot::replot()

Uwe

missoni
19th June 2012, 11:32
Thanks Uwe!
I did in fact use m_plot->replot(), but the problem lay in the color map itself. Due to implicit conversion of float to int I have missed the fact that colors were initialized incorrectly.

Thanks again!