Merging of QGraphicsRectItem
Unsolved
General and Desktop
-
Hi,
I want to develop a functionality where there is push button which will add QGraphicsRectItem on QGraphicsScene. Once there are multiple QGraphicsRectItem on scene, user will select more than one and there will be another button which will merge these selected QGraphicsRectItems into single QGraphicsRectItem having childrenBoundingRect() as merged entities bounding rect. And when I will select merged item on scene it will show me as single item since this merged item will become parent for other children.
Can anybody help me in merging idea?
Manish
-
Two approaches come to mind:
- Keep the single QGraphicsRectItems, but put them together in a QGraphicsItemGroup. This works similar to many drawing programs where you can "group" items together. This is probably a good approach if the user should be able to manipulate the single items in some way, or if you want to be able to split the rectangles again
- Create a new item that paints all the merged rectangle. You can use a QGraphicsPathItem for this.