QPointF pointAfterScale = mapToScene(event.pos());
// Get the offset of how the screen moved
QPointF offset = new QPointF(
pointBeforeScale.x() - pointAfterScale.x(), pointBeforeScale.y() - pointAfterScale.y());
this.horizontalScrollBar().setValue((int) (this.horizontalScrollBar().value()+zoom*offset.x()));
this.verticalScrollBar().setValue((int) (this.verticalScrollBar().value()+zoom*offset.y()));
}
/**
* This method gets called when a key on the keyboard is pressed.