View Full Version : unable to translate QGraphicsView
sven-kt
5th August 2009, 15:08
hi,
do I have to set a flag or anything else if I want to use QGraphicsView->translate()
or why is it not working for me although rotate, scale and shear are working well.
I also tried with QTransform and QMatrix, but I got the same result:
on setTransform and setMatrix only rotate, scale and shear are visible.
I tried different SceneRectangles as well and dont know what else to try...
thanks a lot
sven
wagmare
5th August 2009, 16:56
yes the same thing i am trying for QTransform to rotate the view but no vain ..
in Qt demo chip application
they use QMatrix only to rotate the QGraphicsView()
see in chip/view.cpp
void View::setupMatrix()
{
qreal scale = qPow(qreal(2), (zoomSlider->value() - 250) / qreal(50));
QMatrix matrix;
matrix.scale(scale, scale);
matrix.rotate(rotateSlider->value());
graphicsView->setMatrix(matrix);
setResetButtonEnabled();
}
i dont know why they dont use QTransform
vantulo
5th August 2009, 19:06
sven,
I also tried using translate() and QMatrix but what finally worked was setting the two scrollbars' value; this works even if the scrollbars are turned off:
QScrollBar* myVScrollbar;
myVScrollbar = myView->verticalScrollBar();
myVScrollbar->setValue(myVScrollbar->value() + offsetValue);
QScrollBar* myHScrollbar;
myHScrollbar = myView->horizontalScrollBar();
myHScrollbar->setValue(myHScrollbar->value() + offsetValue);
And subtract offsetValue to move in the opposite direction.
sven-kt
7th August 2009, 09:28
thanks,
moving the scrollbars works, but it doesnt look very precisely as well..
Charlie37
18th January 2010, 17:42
Thank you so much for your tip !
I had the same problem, i.e. QGraphicsView::translate() not working well.
In my case, I had to call it several times to observe a change... ? I tried different SceneRect() as well.
Moving the scrollbars works perfectly for me.
Thanks again
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.