QGraphicsView::centerOn(QPoint) giving a strange result
I'm getting some odd behaviour with centerOn that I need to sort out. It's not putting the selected point in the centre of the screen.. it's scrolling past the screen centre even though I have made sure the view is set to Qt::AlignCenter.
eg:
Code:
myView->setAlignment(Qt::AlignCenter);
myScene->importImages(selection);
myScene->setSceneRect(myScene->itemsBoundingRect());
qDebug
() <<
"loadSelection #1" << myView
->sceneRect
() << myScene
->sceneRect
() << myScene
->sceneRect
().
center() << myView
->mapFromScene
(myScene
->sceneRect
().
center()) << myView
->mapFromScene
(QPointF(0.0,
0.0));
myView->centerOn(myScene->sceneRect().center());
qDebug
() <<
"loadSelection #2" << myView
->sceneRect
() << myScene
->sceneRect
() << myScene
->sceneRect
().
center() << myView
->mapFromScene
(myScene
->sceneRect
().
center()) << myView
->mapFromScene
(QPointF(0.0,
0.0));
gives the result:
Code:
[Qt Message] loadSelection #1 QRectF(0,0 1358x1028.39) QRectF(0,0 1358x1028.39) QPointF(679, 514.194) QPoint(679,514) QPoint(0,0)
[Qt Message] loadSelection #2 QRectF(0,0 1358x1028.39) QRectF(0,0 1358x1028.39) QPointF(679, 514.194) QPoint(48,122) QPoint(-631,-392)
as you can see, the centre is actually placed at (48, 122) instead of where it should be at (180, 320) on a view of (360, 640).
Any ideas?