我有一个场景(0,0,2000,2000)作为矩形协调。 现在我只想在场景上绘制一些点,如图坐标
喜欢场景中项目的(-x,+ y,+ x,-y)。
考虑具有笛卡尔坐标点xMin,xMax,yMin,yMax 所以我把它作为QGraphicsPolyGonItem。 但我不知道如何将它作为场景中的图形坐标点添加到场景中。
答案 0 :(得分:0)
场景由QRect定义(参见其构造函数)。所以,如果你定义你的场景:
QGraphicsScene scene( -1000, -1000, 2000, 2000 );
QGraphicsView view;
view.setScene( scene );
QGraphicsRectItem* it = new QGraphicsRectItem( -10, -10, 20, 20)
scene.addItem( it ); // draw a rectangle
it.setPos( 0, 0 ); // Move to (0;0) and at the center of the view
您可以在(-1000; -1000)和(1000; 1000)之间设置坐标。