1. Beginner
Join Date
Feb 2008
Posts
6
Qt products
Platforms

## Problems understanding QGraphicsScene

Hello,

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

I have a look at this constructor:
Qt Code:
`QGraphicsScene(double x, double y, double width, double height, QObject parent)`
To copy to clipboard, switch view to plain text mode

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

Join Date
Oct 2006
Posts
279
Thanks
6
Thanked 40 Times in 39 Posts
Qt products
Platforms

## Re: Problems understanding QGraphicsScene

x and y are the origin of the coordinate system which doesn't have to be (0, 0).

3. Beginner
Join Date
Feb 2008
Posts
6
Qt products
Platforms

## Re: Problems understanding QGraphicsScene

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)?

Join Date
Oct 2006
Posts
279
Thanks
6
Thanked 40 Times in 39 Posts
Qt products
Platforms

## Re: Problems understanding QGraphicsScene

Originally Posted by Bocki
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).
Originally Posted by Bocki
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.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.