2016-06-07 56 views
0

我总是有QGraphicsScene坐标系统的麻烦。我的场景创建简单如此:如何让QGraphicsScene的左上角与QGraphicsView的左上角重合?

scene = new QGraphicsScene(this); 
this->setScene(scene); 

这里是QGraphicsView。现在我想在(0,0)处绘制一个矩形,这会创建大致位于屏幕中间的矩形。我如何使(0,0)对应于我的视图的左上角?这让我知道在哪里可以放置任何东西......

回答

1

呦可以试试这个方法:QGraphicsView::setAlignment(Qt::Alignment alignment)see here

你将不得不使用这样的:

scene->setAlignment(Qt::AlignTop|Qt::AlignLeft); 
+0

它的工作!谢谢 – aarelovich

相关问题