Reputation: 303
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);
}
Upvotes: 1
Views: 961
Reputation: 243887
You have to set the alignment
in the QGraphicsView
:
QGraphicsView* view = new QGraphicsView(scene);
view->setAlignment(Qt::AlignTop | Qt::AlignLeft);
Upvotes: 2