这看起来微不足道,但我没有找到解决方案。我要做的就是设置一个坐标系统,QGraphicsScene -10,-10到10, 10,然后在场景中绘制一个QRect,使用场景的坐标系。
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);我在这个例子中期望的是一个在左下角边框的矩形边框。我还尝试了mapToScene()和fitInView(),但也没有得到预期的结果。
谢谢你的帮助。
发布于 2012-03-12 16:56:17
我认为您正在寻找QGraphicsView::setSceneRect(),它告诉视图要显示场景的哪一部分。
https://stackoverflow.com/questions/9663982
复制相似问题