PDA

View Full Version : QGraphicsView widget, QGraphicsScene. Default 0.0.



kloopa
3rd January 2016, 08:11
Hi!
By default point 0.0 at top left corner. How to make the lower left corner as 0.0?

1160311604

prasad_N
4th January 2016, 06:33
You can use QGraphicsScene::setSceneRect(QRectF),. It will set logical coordinates you want.

Ex : if your scene geomerty is 0,0, width , height
I think what you can do is :
scene->setSceneRect(0, heigh, width, -height);

kloopa
5th January 2016, 07:57
Thank you for reply.
I tried, not working.



self.ui.graphicsView.scene = QtWidgets.QGraphicsScene()
self.ui.graphicsView.setScene(self.ui.graphicsView .scene)
self.ui.graphicsView.scene.setSceneRect(0, 650, 500, -650)
self.ui.graphicsView.setRenderHints(QPainter.Antia liasing)
path = QPainterPath()
path.moveTo(20.0, 20.0)
path.lineTo(50, 20)
path.moveTo(20.0, 20.0)
path.lineTo(20, 50)
self.ui.graphicsView.scene.addPath(path)


11606

kloopa
7th January 2016, 15:24
No more ways to do this?

anda_skoa
7th January 2016, 17:06
You could try a transformation.

Translate to the bottom left point and scale with 1/-1

Cheers,
_

kloopa
8th January 2016, 13:38
Do you have example how to do this?