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.

    1. 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.
    2. 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);

  • Moderators

    @sunil.nair
    you would need to scale the view whenever a resize happens.
    This can be done with fitInView() or scale() "manually"



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.