PDA

View Full Version : I get he impression that Qgrapchiscene and Qgrapchisview are sometimes redundant ?



tonnot
1st September 2011, 15:22
At diagramscene example I see :


scene->update();
view->update();

I also see :

DiagramScene::mousePressEvent(QGraphicsSceneMouseE vent *mouseEvent)

The model-view applied to this is some confused.....
It is as the two objects were sharing something ....
Who is the responsible of draw ?
Can I create a mix - object ? (On object with the mixed of both)
Is it possible ? It is a bad - good idea ?

Any explication?
Thanks

ChrisW67
1st September 2011, 23:36
Who is the responsible of draw ?
The view is the only thing doing any drawing. As the QGraphicsScene docs say:

Note that QGraphicsScene has no visual appearance of its own; it only manages the items. You need to create a QGraphicsView widget to visualize the scene.
Mouse events on the view are translated into their equivalent event in the scene and forwarded, which is why the scene has these events.

Can I create a mix - object ? (On object with the mixed of both)
You have to have a scene and a view (or views) somewhere. If they are both member variables of, for example, the main window class then that makes sense (but is not mandatory).