Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how to sync zoom in two graphicviews with a single mouse wheelevent.

how to sync zoom in two graphicviews with a single mouse wheelevent.

Scheduled Pinned Locked Moved General and Desktop
zoomgraphicviewqframe
2 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vinay133
    wrote on 29 Sept 2015, 07:50 last edited by
    #1

    i have a tab, in that tab, i added two frames(frame is separate class).this frame class calls the graphic view class(graphicview is also a seperate class). In the grapicsview class i am displaying images through graphicscene. this graphicsview consists of mouse wheelevent, when the mouse wheel is scrolled,the image gets zoomed in/out, my requirement is when i zoom one image both images should zoomed. please help me how to approach this, and provide your valuable suggestions or solutions. please help me.

    vinay

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 29 Sept 2015, 14:57 last edited by
      #2

      Hi and welcome
      Many ways to do this, but here is my suggestion.

      Add a signal to your graphicview class

      signals:
          void MWheelActivated(bool ZoomIn);
      

      and hook it up to a slot in your mainwindow with the connect function.
      http://doc.qt.io/qt-5.5/signalsandslots.html

      then in GraphicsView::wheelEvent(QWheelEvent *e)
      you
      emit MWheelActivated ( (e->delta() > 0));
      and No zooming here!

      Then in mainwindow slot

      mainwindow:: MWheelActivated ( bool ZoomIn )
      {
      	if ( ZoomIn ) {
      		view1->zoomIn ( 6 );
      		view2->zoomIn ( 6 );
      	} else {
      		view1->zoomOut ( 6 );
      		view2->zoomOut ( 6 );
      	}
      }
      

      Hope it helps.

      1 Reply Last reply
      0

      1/2

      29 Sept 2015, 07:50

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved