PDA

View Full Version : Center based image zooming



plagoon
24th April 2010, 15:36
I have a small application that reads in an image and allows zooming in and zooming out.
What I don't know how to implement is once the image exceeds the size of the scrollable area and the scroll bars appear, I would like the center of the image to remain constant as I continue to zoom in, and have both scroll bar "handles" remain centered in the scroll bar. As I zoom out, I would like the same behavior. I'm using Qt 4.5

Thanks

JohannesMunk
25th April 2010, 11:11
Hi Plagoon,

Have you tried http://doc.trolltech.com/4.3/qscrollarea.html#alignment-prop ?

Johannes

plagoon
25th April 2010, 16:09
I found a solution, once I've zoomed in, I simply set myScrollBar->setValue( (scrollBar->maximum() - scrollBar->minimum())/2 ).
Thanks.