0

我有一个 (0, 0, 2000, 2000) 协调为矩形的场景。现在我只想在场景上绘制一些点,比如图形坐标

像场景中的项目的 (-x, +y , +x, -y) 。

考虑有一个笛卡尔坐标点 xMin, xMax, yMin, yMax 所以我把它做成 QGraphicsPolyGonItem 。但我不知道如何将其作为场景中的图形坐标点添加到场景中。

4

1 回答 1

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) 之间设置坐标。

于 2013-04-08T07:49:01.950 回答