如何将(0,0)设置到QGraphicsScene的左上角

How to set (0,0) to the top left corner of QGraphicsScene

QGraphicsScene左上角可以设置(0,0)吗?它似乎默认位于视图的中心:

class GraphicsScene : public QGraphicsScene
{
protected:
    void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override
    {
        // here you can see that (0,0) is at the center of the view
        qDebug() << "movement " << event->scenePos();
    }
};

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    GraphicsScene* scene = new GraphicsScene;
    QGraphicsView* view = new QGraphicsView(scene);

    setCentralWidget(view);
}

您必须设置 alignment in the QGraphicsView:

QGraphicsView* view = new QGraphicsView(scene);
view->setAlignment(Qt::AlignTop | Qt::AlignLeft);