Unsolved How to move origin point of QGraphicsView to its Center?
-
Hello, I am trying to implement cartesian coordinate system on QGraphicsView. But unlike cartesian coordinate system, QGraphicsView's origin point starts at left top. I tried to move it to the center like this:
QPoint MyGraphicsView::centerOriginPoint(QPoint clickedPoint) { QPoint originPoint(ORIGINX,ORIGINY); // ORIGINX: WIDTH/2 , ORIGINY: HEIGHT/2 clickedPoint.setX(clickedPoint.x()-ORIGINX); clickedPoint.setY(ORIGINY-clickedPoint.y()); return clickedPoint; }
It works when I print clicked point on console. But whenever I need to add an
item
onQGraphicsScene
I need to do re-add the values that I substracted. Is there a better way to do this? Can I somehow setQGraphicsView
's orQGraphicsView
's origin to its center without substracting or adding values? Please excuse my poor English. -