View Full Version : about QGraphicsScene ,QGrahpicsView and QGrahpicsPixmapItem
ggs0110
12th July 2007, 08:03
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?
I suggest you start with reading about the graphics view framework (http://doc.trolltech.com/4.3/graphicsview.html) and checking out the graphics view examples (http://doc.trolltech.com/4.3/examples.html#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.
ggs0110
14th July 2007, 04:09
thanks jpn!:D
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?:confused:
But, how to add the QGraphicsPixmapItem object into the QGrahphicsScene object?
The most easiest way is to use QGraphicsScene::addPixmap().
ggs0110
15th July 2007, 04:38
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? :confused:
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!:confused::confused:
Gopala Krishna
15th July 2007, 05:29
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.
ggs0110
4th August 2007, 04:29
thanks a lot
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.