Results 1 to 7 of 7

Thread: about QGraphicsScene ,QGrahpicsView and QGrahpicsPixmapItem

  1. #1
    Join Date
    Jun 2007
    Posts
    10

    Question about QGraphicsScene ,QGrahpicsView and QGrahpicsPixmapItem

    hi!
    I want to know the relationship about QGraphicsScene object ,QGraphicsView object and
    QGraphicsPixmapItem,who can tell me? thanks a lots!

    for example,one QGraphicsView can cantain one or more scene? one scene can cantain one or more item? .....
    And how to add the QGraphicsPixmapItem object into the QGrahphicsScene object?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: about QGraphicsScene ,QGrahpicsView and QGrahpicsPixmapItem

    I suggest you start with reading about the graphics view framework and checking out the graphics view examples. QGraphicsView visualizes the contents of a (single) QGraphicsScene. Multiple views can visualize the same scene. A scene may contain loads of QGraphicsItems.
    J-P Nurmi

  3. #3
    Join Date
    Jun 2007
    Posts
    10

    Default Re: about QGraphicsScene ,QGrahpicsView and QGrahpicsPixmapItem

    thanks jpn!
    But, how to add the QGraphicsPixmapItem object into the QGrahphicsScene object? I know it can be added into the QGraphicsScene object from a doc.Am I right?

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: about QGraphicsScene ,QGrahpicsView and QGrahpicsPixmapItem

    Quote Originally Posted by ggs0110 View Post
    But, how to add the QGraphicsPixmapItem object into the QGrahphicsScene object?
    The most easiest way is to use QGraphicsScene::addPixmap().
    J-P Nurmi

  5. #5
    Join Date
    Jun 2007
    Posts
    10

    Default Re: about QGraphicsScene ,QGrahpicsView and QGrahpicsPixmapItem

    yes!
    for example:

    1. QGrahphicsScene* scene=new QGraphicsScene(this);
    2. scene->addPixmap(filename);//filename is image file's name
    3. QGraphicsView* mainview=new QGraphicsView(scene);

    Now,am I add the QGraphicsPixmapItem object into the scene?

    Another question is:
    if the line 1 and 2 run twice,are there two QGraphicsScene object? I add the line 1,2 and 3 into the open() which to open an image file,if I execute the open() twice and to open two different image,what happened to the scene? are there two items in the scene?or there are two QGraphicsScene objects? very confused!

  6. #6
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: about QGraphicsScene ,QGrahpicsView and QGrahpicsPixmapItem

    Did you read the documentation ? (links given by jpn)
    If not, please consider my friendly suggestion to go through it since you can answer all these questions yourself

    Anyway here is an obligatory explation
    Line 1 creates a scene object
    Line 2 add a QGraphicsPixmapItem to scene. Yes, indeed it is a convienience method. Take a closer look on what scene::addPixmap() returns and you'll know the answer.
    Line 3 sets up a view for the scene created above.
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  7. #7
    Join Date
    Jun 2007
    Posts
    10

    Default Re: about QGraphicsScene ,QGrahpicsView and QGrahpicsPixmapItem

    thanks a lot

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
  •  
Qt is a trademark of The Qt Company.