PySide6.QtWidgets.QGraphicsItemGroup¶
- class QGraphicsItemGroup¶
- The - QGraphicsItemGroupclass provides a container that treats a group of items as a single item. More…- Synopsis¶- Methods¶- def - __init__()
- def - addToGroup()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - A - QGraphicsItemGroupis a special type of compound item that treats itself and all its children as one item (i.e., all events and geometries for all children are merged together). It’s common to use item groups in presentation tools, when the user wants to group several smaller items into one big item in order to simplify moving and copying of items.- If all you want is to store items inside other items, you can use any - QGraphicsItemdirectly by passing a suitable parent to- setParentItem().- The - boundingRect()function of- QGraphicsItemGroupreturns the bounding rectangle of all items in the item group.- QGraphicsItemGroupignores the ItemIgnoresTransformations flag on its children (i.e., with respect to the geometry of the group item, the children are treated as if they were transformable).- There are two ways to construct an item group. The easiest and most common approach is to pass a list of items (e.g., all selected items) to - createItemGroup(), which returns a new- QGraphicsItemGroupitem. The other approach is to manually construct a- QGraphicsItemGroupitem, add it to the scene calling- addItem(), and then add items to the group manually, one at a time by calling- addToGroup(). To dismantle (“ungroup”) an item group, you can either call- destroyItemGroup(), or you can manually remove all items from the group by calling- removeFromGroup().- # Group all selected items together group = scene.createItemGroup(scene.selecteditems()) # Destroy the group, and delete the group item scene.destroyItemGroup(group) - The operation of adding and removing items preserves the items’ scene-relative position and transformation, as opposed to calling - setParentItem(), where only the child item’s parent-relative position and transformation are kept.- The addtoGroup() function reparents the target item to this item group, keeping the item’s position and transformation intact relative to the scene. Visually, this means that items added via - addToGroup()will remain completely unchanged as a result of this operation, regardless of the item or the group’s current position or transformation; although the item’s position and matrix are likely to change.- The - removeFromGroup()function has similar semantics to- setParentItem(); it reparents the item to the parent item of the item group. As with- addToGroup(), the item’s scene-relative position and transformation remain intact.- See also - __init__([parent=None])¶
- Parameters:
- parent – - QGraphicsItem
 
 - Constructs a - QGraphicsItemGroup.- parentis passed to- QGraphicsItem‘s constructor.- See also - addToGroup(item)¶
- Parameters:
- item – - QGraphicsItem
 
 - Adds the given - itemand item’s child items to this item group. The item and child items will be reparented to this group, but its position and transformation relative to the scene will stay intact.- See also - removeFromGroup(item)¶
- Parameters:
- item – - QGraphicsItem
 
 - Removes the specified - itemfrom this group. The item will be reparented to this group’s parent item, or to 0 if this group has no parent. Its position and transformation relative to the scene will stay intact.- See also