QGrahicsView "translate" has no effect
-
Hello!
I have my custom class derived from QGrahicsView.void my_view::wheelEvent(QWheelEvent *event) { QTransform tf; tf.translate(offset.x(), offset.y()); tf.scale(current_scale, current_scale); tf.rotate(r); setTransform(tf, false); }
Scale - working, rotate - excellent, translate - absolutely no effect! but offset.x/y is changing.
I tried many many things such as:
- setAlignment(0);
- setTransformationAnchor(QGraphicsView::NoAnchor); + setResizeAnchor(QGraphicsView::NoAnchor);
- centerOn(event->pos());
I just want to view different parts of my scene more detailed with higher zoom. Please help me, I'm so much confused and angry that dumb primitive action just move view is not working at all... =(
Which highly intelligent options of QGraphicView I should turn off to make this thing just do what I want without any implicit impacts on my "orders"?
-
My first idea is that the scene is too small. Do you have scrollbars, and if so, can you navigate using them?
Other things to try: fitInView, ensureVisible
-
The scene is automatically translated according to the view's alignment settings. This is done so that the scrollbars work as expected in most use cases. To achieve what you want the easiest way is to set alignment to AlignLeft and AlignTop, make the sceneRect the same size as the view and then don't apply translations to the view but to the sceneRect (= increase / decrease the x and y of the sceneRect). And always disable the scrollbars.