Search code examples
c++qtc++11qt5qwt

QwtPlot setAxisScale, how it works?


I subclassed QwtPlot like:

class RealPlot : public QwtPlot {
public:
    RealPlot () {
        ...
        setAxisScale(QwtPlot::xBottom, -5, 5);
    }
    void addPoint(Point p) {
        ...
        setAxisScale(QwtPlot::xBottom, min, max);
    }
}

And I would like to rescale the (horizontal axis of) plot every time a new point is added. So I call setAxisScale(QwtPlot::xBottom, min, max); just after the point is added to the curve.

The problem is that the plot is not being rescaled. The call to setAxisScale(QwtPlot::xBottom, -5, 5); in the constructor does rescale the plot. But setAxisScale(QwtPlot::xBottom, min, max); does not. Why?


Solution

  • QwtPlot::replot is missing to make your changes happen. In case of startup you always run into an initial replot - that's why it is working there.