Problem while drawing on QGraphicsView after Translation the QGraphicsView.
-
Actually, I want that when i click on view whatever where i clicked, and i move the mouse in whatever direction, items and view should move in that direction.
-
i think @this->translate(dx,dy);@ code is running fine. Problem is with @ this->setSceneRect(-dx,-dy,this->sceneRect().width(), this->sceneRect().height());@ code.
-
well then i understood you right and you should adapt the scrollbars.
-
Sry, bt i do not understand what you want to say.
-
I do not want to use scrollbars.
-
so you want to simulate a QGraphicsScene of infinite size?
The scrollbars would already provide everything you need. But when you don't want to use them you have to struggle with the drawbacks, like you already have.
For example you will also have to translate all event positions etc. in your code... -
Is there nothing in Qt except scrollbars which can solve my problem ??
-
If i use scrollbars, then how it will work ??? please tell me...
-
instead of translateing like you do now add the values (dx,dy) to the horizontal-/vertical-scrollbar respectively.
You can get the scrollbar with QGraphicsView::horizontalScrollBar(). and use QScrollBar::setValue() -
thanku so much sir.... Now, it works very fine.... :)