PDA

View Full Version : QwtScaleWidget: problem with drawing a ColorMap



spagatoni
24th October 2008, 18:22
The problem I am having is that whenever I create and then draw a QwtScaleWidget with my defined color map it doesn't render properly. If I give it a range of 0 - 1 it renders fine but when ever I hand it any other range it does not render properly.

I have listed my code below and some sample screenshots.

Thanks for your time,
Jon Jones



QwtLinearColorMap colorMap(Qt::darkBlue, Qt::red);
colorMap.addColorStop(0.25, Qt::cyan);
colorMap.addColorStop(0.75, Qt::yellow);

QWidget *widget = canvas();

QwtScaleWidget *colorBar = new QwtScaleWidget(widget);
colorBar->setColorMap(QwtDoubleInterval(0, 10), colorMap);
colorBar->setColorBarEnabled(true);
colorBar->drawColorBar(&painter, QRect(10,10, 25, 100));

Uwe
26th October 2008, 19:39
Assuming you want to use the right axis for your color bar:


QwtDoubleInterval range(0, 10);

QwtScaleWidget *scale = plot->axisWidget(QwtPlot::yRight);
scale->setColorBarEnabled(true);
scale->setColorMap(range, colorMap);

plot->setAxisScale(QwtPlot::yRight,
range().minValue(), range().maxValue() );
plot->enableAxis(QwtPlot::yRight);
plot->replot();

The spectrogram example shows a colorbar in the range [0, 10].

Uwe