Reputation: 1186
This seems trivial, but I didn't found a solution. All I want to do is to set up a coordinate system a QGraphicsScene [-10, -10] to [10, 10] (f.e. with setSceneRect(-10, -10, 20, 20)) and to plot a QRect within the scene, using the coordinate system of the scene.
scene = new QGraphicsScene(-10.0, -10.0, 20.0, 20.0, ui->graphicsView);
// scene is already a QGraphicsScene pointer defined in the .h
ui->graphicsView->setScene(scene);
scene->addRect(-8, -8, 4, 4);
What I am expecting in the example is a rectangle bounding at the left-bottom border. I also tried mapToScene() and fitInView(), but that also didn't brought me the expected result.
Thanks for helping.
Upvotes: 0
Views: 2371
Reputation: 2948
I think you are looking for QGraphicsView::setSceneRect() which tells the view what part of the scene to display.
Upvotes: 2