you can find the solution in this form
http://www.qtcentre.org/wiki/index.p...ng_and_Zooming
I used it in my code like this :
//in header file
protected:
//in cpp file
ui
->graphicsView
->setTransformationAnchor
(QGraphicsView::AnchorUnderMouse);
// Scale the view / do the zoom
double scaleFactor = 1.15;
if(event->delta() > 0) {
// Zoom in
ui->graphicsView-> scale(scaleFactor, scaleFactor);
} else {
// Zooming out
ui->graphicsView->scale(1.0 / scaleFactor, 1.0 / scaleFactor);
}
//ui->graphicsView->setTransform(QTransform(h11, h12, h21, h22, 0, 0));
}
//in header file
protected:
virtual void wheelEvent(QWheelEvent* event);
//in cpp file
void Dialog::wheelEvent(QWheelEvent *event){
ui->graphicsView->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
// Scale the view / do the zoom
double scaleFactor = 1.15;
if(event->delta() > 0) {
// Zoom in
ui->graphicsView-> scale(scaleFactor, scaleFactor);
} else {
// Zooming out
ui->graphicsView->scale(1.0 / scaleFactor, 1.0 / scaleFactor);
}
//ui->graphicsView->setTransform(QTransform(h11, h12, h21, h22, 0, 0));
}
To copy to clipboard, switch view to plain text mode
Bookmarks