PDA

View Full Version : QGraphicsView::translate



chaoticbob
30th November 2008, 09:20
I don't seem to understand what QGraphicsView::translate does...was wondering if someone could help me understand it. From what I gathered by reading the documentation, it's suppose to apply the x,y to the transformation matrix. I'm lead to believe that this is suppose to move the scene + content around in the view. However, it just remains fixed at the center. I'm basing this on the QRect that is handed to me in QGraphicsScene::drawBackground. Do I need to apply a transfrom to the rect? If so - how do I get the current view's transform matrix?

I've also tried centerOn with no sucess.

What am I misunderstanding here?

Thanks.

wysota
30th November 2008, 09:50
Is your scene bigger than your view? If not, translating the view won't change anything.

chaoticbob
30th November 2008, 11:05
I see what you mean by that now. How do I translate the origin of my scene in a view so that it's somewhere other than dead center?

Also - do you know if I can turn off that auto scroll when I add items close to the edge of the view?

Thanks.

wysota
30th November 2008, 11:26
The view inherits QAbstractScrollArea. Dig out the rest yourself :)

To anchor the scene to something else than the centre of the view (if it is smaller than the view) use the QGraphicsView::alignment property.

chaoticbob
30th November 2008, 11:30
Thanks. That's a good starting point.