Question
Take the specific QGraphicsItems tree: QGraphicsRectItem, which has two QGraphicsTextItems as children.
QGraphicsRectItem CompositeObject;
QGraphicsTextItem text1;
QGraphicsTextItem text2;
text1.setParent(CompositeObject);
text2.setParent(CompositeObject);
Now take a QGraphicsScene with two QGraphicsRectItem in a different position:
QgraphicsScene scene;
QGraphicsRectItem* rect1 = scene.addRect(...);
QGraphicsRectItem* rect2 = scene.addRect(...);
rect1.setPos(0,0);
rect2.setPos(0,100);
Now I want CompositeObject to be a child of rect1 AND rect2; my goal: to show the same QGraphicsItems subtree in two places in the same scene, trimmed by the parent rectangle. Updates in the subtree will be visible in two places in QGraphicsView without any manual synchronization or such.
The solution I'm not sure about
, , , - QGraphicsViews -. , , (subScene) , QGraphicsViews subScene. , , , - -, , subScene .
QGraphicsScene subScene;
QGraphicsTextItem text1;
QGraphicsTextItem text2;
subScene.addItem(text1);
subScene.addItem(text2);
QgraphicsScene scene;
QgraphicsView view1(&subScene);
QgraphicsView view2(&subScene);
QGraphicsProxyWidget* proxy1 = scene.addWidget(&view1);
proxy1.setPos(0,0);
QGraphicsProxyWidget* proxy2 = scene.addWidget(&view2);
proxy2.setPos(0,100);
, ?