I'm working with QwtLinearColorMap and I'm making interactive colorbar editor where I can interactively addColorStop.
Let suppose the simplest case where I have only two points in colormap: 0 and 1 (min and max values).
Then I change the color at position 1 (to RED).
I do:
Qt Code:
  1. QwtLinearColorMap* colorMap0 = (QwtLinearColorMap*)colorBarWidget->colorMap();
  2. QColor color1 = colorMap0->color1();
  3. QColor color2 = colorMap0->color2();
  4. QwtLinearColorMap* colorMap1 = new QwtLinearColorMap( color1, color2, QwtColorMap::RGB );
  5. colorMap1->addColorStop(1, RED_color);
  6. colorBarWidget->setColorMap(QwtInterval(-100, 100), colorMap1);
  7. colorBarWidget->setColorBarEnabled(true);
To copy to clipboard, switch view to plain text mode 
After that the color of colorbar at position = 1 doesn't change but at the same time I can colorMap1->colorStops() returns me a vector of three components (I can see it in Qt debugger):
  1. first component at a position 0;
  2. second component at a position 1 with oldcolor;
  3. third component at a position 1 with new color.

Also when I type QColor color = colorMap1->color(QwtInterval(0, 1), 1); I get the new color as I want.

Interesting thing is this happens only with point at pos = 1. At position = 0 it works fine.

I work with addColorStop but as can see there is unfortunately no something like removeColorStop method. So when I iteractively change color I create new colormap and there is no way to remove points from this colormap (as I can see).

Now I can solve my problem if I perform the color change code twice: first time colorMap1 has three colorstops (0, 1, 1) and one of them with old color, then I repeat it and colorMap1 has also three points (0, 1, 1) two of them with new color.

Best regards