QScrollArea with "negative" values
-
Hi!
I am working with a QScrollArea that allows zooming and panning of an image.
When I zoom out so far that the whole image is visible (no scrollbars needed), Qt will freeze the image and I cannot pan anymore.Is it possible to still enable panning in that situation?
What I am looking for is a way to allow the scrollbars to work even if the whole image fits inside the QScrollArea.
This would basically mean to allow negative values for QScrollbar.setValue(), but it seems to me like this is not possible.I thought about changing the image size when I get to the edge, but since I am working with coordinates within the image, it is crucial that these values do not change, e.g. when determining the position of the mouse cursor within the widget, so I'm hestiant to just make the image larger. This would also be a waste of resources.
Gimp does something similar to what I have in mind: When the image is panned outside the viewport, the scrollbars extend as if the image was larger than it actually is. As you return to the original position, the scrollbars shrink again until they disappear when the whole image fits inside the viewport.
-
Hi and welcome to devnet,
It sounds that you might be implementing something that could already be available through the Graphics View Framework. You should take a look at it.