1

Is it possible to set (0,0) to the top-left corner of the QGraphicsScene? It seems to be at the center of the view by default:

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);
}
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Thinium
  • 171
  • 1
  • 14

1 Answers1

1

You have to set the alignment in the QGraphicsView:

QGraphicsView* view = new QGraphicsView(scene);
view->setAlignment(Qt::AlignTop | Qt::AlignLeft);
eyllanesc
  • 235,170
  • 19
  • 170
  • 241