2016-06-07 223 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

相關問題