QCustomPlot Discussion and Comments

set maximum ranges of plotReturn to overview

I want to limit the plot size to (-1000,-1000) to (1000,1000).
I tried something with the slot "rangeChanged", but it does not prevent the user from dragging or scrolling past the limits...

Also, how to get the exact visible ranges?
For example when the plot is 20×20 and the center is (-10,10) I'd like to get the values (-30,10) for xAxis and (10,-30) for yAxis

Thanks in advance

So the way i do it is i added a method called 'setBoundingRange()' to QCPAxis, which sets a QCPRange as a maximum value... then in QCPAxis::scaleRange and QCPAxisRect::mouseMoveEvent i use the bounding rect in conjunction with the QCPRange::bounded to prevent the axis from being moved outside of my bounds.

the change i added to the end of QCPAxis::Scale range: