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. QGraphicsView zooming with QSlider
QtWS25 Last Chance

QGraphicsView zooming with QSlider

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 4.7k 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.
  • D Offline
    D Offline
    depecheSoul
    wrote on last edited by
    #1

    Hello! I am trying to make when QSlider changes value it zooms the QGraphicsView.

    So far I have made a QSlider that with every value change zooms the QGraphicsView. This dont work because on every value change of QSlider QGraphicsView zooms even more.

    Can you please give me some guidance how to make that when QSlider moves from bigger value to smaller value the QGraphicsView zooms out.

    For scaling I am using:
    http://qt-project.org/doc/qt-4.8/qgraphicsview.html#scale

    Thank you

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jake007
      wrote on last edited by
      #2

      Hi!

      I'm using "QMatrix":http://qt-project.org/doc/qt-4.8/qmatrix.html to scale up and down.
      Code snippet isn't exactly for QSlider, but...

      @void App::onZoom()
      {
      QMatrix matrix;

      matrix.scale( zoom, zoom); // zoom is zoom factor ( example: 1.1 is 110%)

      ui->graphicsView->setMatrix(matrix);
      }@

      Works like a charm for me :) .
      Had the same problem with scale function ;)

      Hope it helps.
      Regards,
      Jake


      Code is poetry

      1 Reply Last reply
      0
      • D Offline
        D Offline
        depecheSoul
        wrote on last edited by
        #3

        Thank you Jake007. Hope someone will help me with QSlider.

        1 Reply Last reply
        0
        • ? This user is from outside of this forum
          ? This user is from outside of this forum
          Guest
          wrote on last edited by
          #4

          [quote author="depecheSoul" date="1332708102"]Thank you Jake007. Hope someone will help me with QSlider. [/quote]

          Just use the code snippet from Jake007 and instead of zoom factor use the value from your slider, set the range for the slider to the amount of zooming in and out you want and you are done.

          1 Reply Last reply
          0

          • Login

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