Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Is this a bug or undocumented feature in 'void QGraphicsItemGroup::addToGroup(QGraphicsItem *item)' ?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kleimola
    wrote on last edited by
    #1

    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.

    >> Johannes <<

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sigrid
      wrote on last edited by
      #2

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

      http://bugreports.qt.nokia.com/browse/QTBUG-19808

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kleimola
        wrote on last edited by
        #3

        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)
        child->setParent(0);

        someGroup->addToGroup(itemToBeAdded);

        foreach (QGraphicsItem *child, childItemList)
        child->setParent(itemToBeAdded);
        @

        >> Johannes <<

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved