QGraphicsView zooming with QSlider
-
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#scaleThank you
-
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 -
Thank you Jake007. Hope someone will help me with QSlider.
-
[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.