Unsolved Position of QGraphicItem in a QGraphicScene
-
My aim is that the graphics items inside a qgraphicsview should not move when I resize the GraphicsView window.
- Currently, they seem to be in a default layout inside the graphics scene. When I resize the graphics view, the items move along with it.
- When I try to print a QGraphicitem->scenePos, the value does not change when I resize the QGraphicsView which contains the QGraphicsScene. ```
QGraphicsView *view = new QGraphicsView(this);
QGraphicsScene *scene = new QGraphicsScene();
QGraphicsItem *imageItem=scene()->addWidget(pixmap);
view->setScene(scene);
-
@sunil.nair
you would need to scale the view whenever a resize happens.
This can be done with fitInView() or scale() "manually" -
I had the same problem with items moving rightward as I stretched the window/viewport beyond the scene rect. This fixed it:
view->setAlignment( Qt::AlignLeft | Qt::AlignTop );