Quote Originally Posted by d_stranz View Post
In the views, you need to handle the mouse events associated with zooming. Since you are already doing this in a single view, all you need is to add some signals to let the main window (or whoever holds the zoom manager instance) know what is going on. It is also important to move whatever code there is in your event handler that does the zooming to the ZoomTo() methods (and to let the zoom manager handle those calls - otherwise you get double updates).

When one of the zoom manager's zoom or pan methods is called, it relays the zoom region to each of the linked views, so that all views are synchronized.
Finally got to make this work (my pet project, so takes its time). Zooming is working fine. I have a two~four (depends on my config) images showing and I can zoom on any one of them and the others zoom in sync.


However, I have run into issues during panning.

For panning, I have connected the horizontalscrollbar signal my derived graphicsview class thus:
Qt Code:
  1. connect(this->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(panImage(int)));
To copy to clipboard, switch view to plain text mode 

and the panImage function is the following.
Qt Code:
  1. void myGraphicsView::panImage(int nTmp) {
  2. if (nTmp != m_nCurrScrollPos) {
  3. if (NULL != m_pMain) {
  4. //get the panned scene's rectangle
  5. QRectF SceneRectPanned = mapToScene(viewport()->geometry()).boundingRect();
  6. float x1New = SceneRectPanned.left() ;
  7. float x2New = SceneRectPanned.right() ;
  8. float y1New = SceneRectPanned.top() ;
  9. float y2New = SceneRectPanned.bottom() ;
  10.  
  11. //ZoomXY just required the new rectangle, give it the panned rect to pan the views.
  12. m_pMain->m_pZM->ZoomXY(x1New, x2New, y1New, y2New);
  13. }
  14. m_nCurrScrollPos = nTmp;
  15. }
  16. }
To copy to clipboard, switch view to plain text mode 
Here, m_pMain is the pointer to my class that shows the images, etc. and also contains the zoomer instance m_pZM.

I seem to be running into recursions. I am pretty sure it is a basic mistake. But what !?


Thanks.