Results 1 to 4 of 4

Thread: Problems understanding QGraphicsScene

  1. #1
    Join Date
    Feb 2008
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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:
    1. 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

  2. #2
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problems understanding QGraphicsScene

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

  3. #3
    Join Date
    Feb 2008
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

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

  4. #4
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problems understanding QGraphicsScene

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

Bookmarks

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.