I am using QCP to display an optical image as a QCPItemPixmap with a colormap overlayed on top of it.
I am making sure the image cannot be zoomed/dragged out further than the bounding box using QCPRange::bounded function. I do this using the beforeReplot() signal (the rangeChanged(QCPRange) required twice as much replotting because of both axes). Simply:
plot->xAxis->setRange(plot->xAxis->range().bounded(overlay_plot_min_range, overlay_plot_max_range)); plot->yAxis->setRange(plot->yAxis->range().bounded(overlay_plot_min_range, overlay_plot_max_range));
This is the only "custom code" I use for the zooming feature, I let the built in drag/zoom interactions do everything else.
One issue I am having is that when zooming in to the picture quite a lot, it eventually disappears and shows my existing background gradient, and I get the following in my Application Output pane:
QImage: out of memory, returning null.
Is there a way I can limit the amount of zoom using the scroll wheel?