Important: Please read the Qt Code of Conduct -

Is this a bug or undocumented feature in 'void QGraphicsItemGroup::addToGroup(QGraphicsItem *item)' ?

  • The documentation clearly states that the function reparents the passed item to the group, but it also seems to set the 'QGraphicsItemGroup * QGraphicsItem::group () const' -pointer of all of that item's own children to this same group (not touching parentItem() -pointer of course)! This behavior is not documented and it messes up the easy distinction whether a specific item belongs to a group or is a child of another item that belongs to a group.

    This could be a bug or just documentation shortage. I'm currently seeing this in Qt 4.7.3.

  • This sounds like a shortcoming of the documentation. I have asked our documentation team to add this information to the documentation, see:

  • Thank you.

    If this behavior is not wanted (as in my case) you can circumvent it by removing and reparenting the children. Example below

    QList<QGraphicsItem *> childItemList = itemToBeAdded->childItems();
    foreach (QGraphicsItem *child, childItemList)


    foreach (QGraphicsItem *child, childItemList)

Log in to reply