PDA

View Full Version : Problems understanding QGraphicsScene



Bocki
15th February 2008, 12:04
Hello,

I've read the documentation for QGraphicsScene but unfortunately I don't understand a central point:

I have a look at this constructor:

QGraphicsScene(double x, double y, double width, double height, QObject parent)

Whats the difference between x and width and y and height? I thougt that I have a "virtual table" (the QGraphicScene) on which I can put my items. But for that I would just have to give two dimensions, width and height. What do I need the other dimensions x and y for?

Thanks for your patience explaining this basic thing to me!

Bocki

spud
15th February 2008, 12:30
x and y are the origin of the coordinate system which doesn't have to be (0, 0).

Bocki
15th February 2008, 12:45
Oh, ok, that's really easy. Thanks for that hint.

Two more questions in this context:

Is the origin of the coordinate system always in the top left or can i change that?

Are the boundaries "hard"? In other words: What happens if I create a QGraphicsScene with QGraphicsScene(0, 0, 500, 500) and then try to put an item let's say at position (-50,-50)?

spud
15th February 2008, 13:43
Is the origin of the coordinate system always in the top left or can i change that?

You can apply any affine transformation to the scene. You do this by changing its matrix.
To have origo in the lower left corner, you just scale(1,-1).

Are the boundaries "hard"?

No, the framework is quite flexible. In fact if you don't specify a sceneRect it will grow as you add items to encompass them all.