Haven't been able to get this down pat....kinda feel like a noob because of this, so I thought I'd post in this area.
I use a rubberband to enlarge the scene using qgraphicsview's scale.
here's the code for it:
if(this->viewport()->width()>this->viewport()->height())
increaseZoom = this->viewport()->height()/m_deltaMouseZoomY;
else
increaseZoom = this->viewport()->width()/m_deltaMouseZoomX;
double offSetX = this->viewport()->width() - m_deltaMouseZoomX;
double offSetY = this->viewport()->height() - m_deltaMouseZoomY;
scale(increaseZoom, increaseZoom);
this->verticalScrollBar()->setSliderPosition(mapFromScene(m_zoomInStartPointScene).y()-this->viewport()->height()+(offSetY/2));
this->horizontalScrollBar()->setSliderPosition(mapFromScene(m_zoomInStartPointScene).x()-this->viewport()->width()+(offSetX/2));
if(this->viewport()->width()>this->viewport()->height())
increaseZoom = this->viewport()->height()/m_deltaMouseZoomY;
else
increaseZoom = this->viewport()->width()/m_deltaMouseZoomX;
double offSetX = this->viewport()->width() - m_deltaMouseZoomX;
double offSetY = this->viewport()->height() - m_deltaMouseZoomY;
scale(increaseZoom, increaseZoom);
this->verticalScrollBar()->setSliderPosition(mapFromScene(m_zoomInStartPointScene).y()-this->viewport()->height()+(offSetY/2));
this->horizontalScrollBar()->setSliderPosition(mapFromScene(m_zoomInStartPointScene).x()-this->viewport()->width()+(offSetX/2));
To copy to clipboard, switch view to plain text mode
This code is almost right, but sometimes you need to adjust the scroll bars just a little so that whatever was in the rubberband stays in centred in the viewport.
many thanks to anyone who can figure out why this is so close but off by a couple of clicks on the the scroll bars.
Bookmarks