How to zoom into a specific point in an image?
Unsolved
General and Desktop
-
I'm using a wheelEvent and a paintEvent to implement zooming functionality into an image , I use a custom class derived from QLabel and paint to it in my paintEvent
my question is how can I zoom into a specific point instead of (0,0) changing x,y for the drawImage function shifts my whole image out of the component
here is my code for refrencevoid zoompan::paintEvent ( QPaintEvent * event ) { QPainter p(this); p.scale(scale,scale); //paint here p.drawImage(0,0,img); } void zoompan::wheelEvent ( QWheelEvent * event ) { scale+=event->angleDelta().y()/240.0; origin=event->position(); if(scale<1) { scale=1; origin=QPointF(0,0); } update(); }
-
Hi,
Do you mean grab the mouse pointer position to start the zoom ?
-
I just realised something, you would likely simplify your life using the Graphics View framework.
You have an example here.
-
You can replace the content of the time with QGraphicsPixmapItem::setPixmap.