Hi,

by default, when we add an item in a QGraphicsScene the view tries to center it. If we add one more it tries to center both... I'd like to have it "static", a viewport unable to move.

In order to do that I set the size of the scene to the view:

Qt Code:
  1. //Scene
  2. pScene = new QGraphicsScene(ui->view);
  3. pScene->setSceneRect(0, 0, ui->view->width(), ui->view->height());
  4. //View
  5. ui->view->setInteractive(false);
  6. ui->view->setScene(pScene);
  7.  
  8.  
  9. QGraphicsTextItem* txtG = pScene->addText("G");
  10. txtG->setPos(0, 0);
  11. QGraphicsTextItem* txtD = pScene->addText("D");
  12. txtD->setPos(110, 110);
To copy to clipboard, switch view to plain text mode 

It solves the problem, but the coordinates seem to be wrong, 0, 0 should be corner top-left and it's close to the view's center.

Does anybody know how I can solve this problem or any other way to "fix the viewport"?

thanks!