pythonpyqtqgraphicsviewqgraphicsitemqgraphicsitemgroup

Make children of QGraphicsItemGroup unselectable


In my app I am using the Graphics View framework and I am creating a lot of QGraphicsItemGroup. For example one group represents a text frame with some squares to resize the frame and another is a group of points representing a brush stroke. I am implementing a selection tool similar to the one you can find in Adobe Photoshop or Indesign. I implemented it as follow:

However the item returned by itemAt is sometimes just a child of the group itself. Is there a way to make the function itemAt() returning the group of the item ? Or in another way, to make those children unselectable.


Solution

  • If you are looking to get the group of the item

    Below method available for QGraphicsItem, which returns QGraphicsItemGroup. Use this group object and set the desired.

    PySide6.QtWidgets.QGraphicsItem.group()
    

    https://doc.qt.io/qtforpython/PySide6/QtWidgets/QGraphicsItem.html?highlight=qgraphicsitem#PySide6.QtWidgets.PySide6.QtWidgets.QGraphicsItem.group