I use my plot classes based on qwtplot, code can be viewed here: https://github.com/pospiech/code/tree/master/libdev/plot/plottools/trunk/src
This code is used in another application, here I create qwtplot classes (QMatrixPlot) and add data and call replot
plot2DAmplitude->setMatrixData(QVector<double>::fromStdVector(dataAmplitude),
xaxis.size(),
QwtInterval(xaxis.front(), xaxis.back()),
QwtInterval(yaxis.front(), yaxis.back()));
plot2DAmplitude->replot();
setMatrixData
is the following code:
void setMatrixData(const QVector< double > &values, int numColumns, QwtInterval xAxisRange, QwtInterval yAxisRange)
{
m_MatrixRasterData->setInterval( Qt::XAxis, xAxisRange );
m_MatrixRasterData->setInterval( Qt::YAxis, yAxisRange );
double minValue = *std::min_element( std::begin(values), std::end(values) );
double maxValue = *std::max_element( std::begin(values), std::end(values) );
m_MatrixRasterData->setInterval( Qt::ZAxis, QwtInterval(minValue, maxValue) );
m_MatrixRasterData->setValueMatrix (values, numColumns);
d_spectrogram->setData( m_MatrixRasterData );
const QwtInterval zInterval = d_spectrogram->data()->interval( Qt::ZAxis );
setAxisScale( QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue() );
QwtScaleWidget *axis = axisWidget( QwtPlot::yRight );
axis->setColorMap( zInterval, QColorMap::map(d_mapType) );
}
This works - once. The second call with different data does nothing, although the same code is called. Only If I zoom in and out the data gets an update.
Any idea? Qwt is version 6.1.3. Once I finish a minimal example I will update this post.
QwtPlotRasterItem caches the rendered image. In your code you are changing the data behind the back of the item, so the item is not aware of the cache being invalid.
With QwtPlotRasterItem::invalidateCache() you can solve problems like this one.