Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    QGraphicsView zooming with QSlider

    General and Desktop
    2
    4
    4449
    Loading More Posts
    • 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
      depecheSoul last edited by

      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 Reply Quote 0
      • J
        Jake007 last edited by

        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 Reply Quote 0
        • D
          depecheSoul last edited by

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

          1 Reply Last reply Reply Quote 0
          • ?
            Guest last edited by

            [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 Reply Quote 0
            • First post
              Last post