Hi,
I can't send you the code as I do not have permision to do so. I will send the (rectangle/size/etc) within 15 minutes.
Here it is:
The code I am using to print values:
// the given _rectangle for zooming
qDebug()<<(_rectangle.bottomLeft().rx())<<(_rectangle.bottomLeft().ry());
qDebug()<<(_rectangle.bottomRight().rx())<<(_rectangle.bottomRight().ry());
qDebug()<<(_rectangle.topLeft().rx())<<(_rectangle.topLeft().ry());
qDebug()<<(_rectangle.topRight().rx())<<(_rectangle.topRight().ry());
m_view->fitInView(_rectangle,Qt::KeepAspectRatio); // or Qt::KeepAspectRatioBy expanding
// Scene rectangle
_rectangle = m_view->sceneRect(); qDebug()<<(_rectangle.bottomLeft().rx())<<(_rectangle.bottomLeft().ry());
qDebug()<<(_rectangle.bottomRight().rx())<<(_rectangle.bottomRight().ry());
qDebug()<<(_rectangle.topLeft().rx())<<(_rectangle.topLeft().ry());
qDebug()<<(_rectangle.topRight().rx())<<(_rectangle.topRight().ry());
// scene rectangle(from view)
_rectangle = m_scene->sceneRect(); qDebug()<<(_rectangle.bottomLeft().rx())<<(_rectangle.bottomLeft().ry());
qDebug()<<(_rectangle.bottomRight().rx())<<(_rectangle.bottomRight().ry());
qDebug()<<(_rectangle.topLeft().rx())<<(_rectangle.topLeft().ry());
qDebug()<<(_rectangle.topRight().rx())<<(_rectangle.topRight().ry());
// view size
qDebug()<<m_view->size().height()<<m_view->size().width();
//view matrix
qDebug()<<m_view->matrix().m11()<<m_view->matrix().m12()<<m_view->matrix().m21()<<m_view->matrix().m22()<<m_view->matrix().det()<<m_view->matrix().dx()<<m_view->matrix().dy();
// the given _rectangle for zooming
qDebug()<<(_rectangle.bottomLeft().rx())<<(_rectangle.bottomLeft().ry());
qDebug()<<(_rectangle.bottomRight().rx())<<(_rectangle.bottomRight().ry());
qDebug()<<(_rectangle.topLeft().rx())<<(_rectangle.topLeft().ry());
qDebug()<<(_rectangle.topRight().rx())<<(_rectangle.topRight().ry());
m_view->fitInView(_rectangle,Qt::KeepAspectRatio); // or Qt::KeepAspectRatioBy expanding
// Scene rectangle
_rectangle = m_view->sceneRect(); qDebug()<<(_rectangle.bottomLeft().rx())<<(_rectangle.bottomLeft().ry());
qDebug()<<(_rectangle.bottomRight().rx())<<(_rectangle.bottomRight().ry());
qDebug()<<(_rectangle.topLeft().rx())<<(_rectangle.topLeft().ry());
qDebug()<<(_rectangle.topRight().rx())<<(_rectangle.topRight().ry());
// scene rectangle(from view)
_rectangle = m_scene->sceneRect(); qDebug()<<(_rectangle.bottomLeft().rx())<<(_rectangle.bottomLeft().ry());
qDebug()<<(_rectangle.bottomRight().rx())<<(_rectangle.bottomRight().ry());
qDebug()<<(_rectangle.topLeft().rx())<<(_rectangle.topLeft().ry());
qDebug()<<(_rectangle.topRight().rx())<<(_rectangle.topRight().ry());
// view size
qDebug()<<m_view->size().height()<<m_view->size().width();
//view matrix
qDebug()<<m_view->matrix().m11()<<m_view->matrix().m12()<<m_view->matrix().m21()<<m_view->matrix().m22()<<m_view->matrix().det()<<m_view->matrix().dx()<<m_view->matrix().dy();
To copy to clipboard, switch view to plain text mode
HEre is the result:
-172 38
78 38
-172 -112
78 -112
-50 80
50 80
-50 50
50 50
-50 80
50 80
-50 50
50 50
660 1224
4.34667 0 0 4.34667 18.8935 0 0
QGraphicsScene::removeItem: item 01F45440's scene (00000000) is different from this scene (01AB88D8)
-51.3037 67.408
11.1963 67.408
-51.3037 29.908
11.1963 29.908
-50 80
50 80
-50 50
50 50
-50 80
50 80
-50 50
50 50
660 1224
17.3867 0 0 17.3867 302.296 0 0
QGraphicsScene::removeItem: item 01E9E968's scene (00000000) is different from this scene (01AB88D8)
-30.8857 57.2278
-15.2607 57.2278
-30.8857 47.8528
-15.2607 47.8528
-50 80
50 80
-50 50
50 50
-50 80
50 80
-50 50
50 50
660 1224
67.84 0 0 67.84 4602.27 0 0
QGraphicsScene::removeItem: item 01F78660's scene (00000000) is different from this scene (01AB88D8)
-19.487 52.5501
-15.5808 52.5501
-19.487 50.2064
-15.5808 50.2064
-50 80
50 80
-50 50
50 50
-50 80
50 80
-50 50
50 50
660 1224
271.36 0 0 271.36 73636.2 0 0
I have used zoom In 4 times here and after the second Zoom IN my widgets(created with m_view->viewport() as the parent) moved left. I tried to recreate the widgets after zooming In (removing items and addint them once again) that's why I get the "removeITem" warning.
Maverick
Bookmarks