Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-76859

After changing the parent/parentItem of a child item, its previous parent still destroys it

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 5.12.2, 5.12.3, 5.12.4, 5.13.0
    • None
    • macOS

    Description

      I have a Component that contains a Rectangle (parentRect) and a Component inside that's also a rectangle (childRect). I dynamically create the parentRect and parent it to the window. There's a button that's inside the parentRect and that one creates childRect and parents it to parentRect.

      When I re-parent the childRect to another rectangle and destroy the original parentRect, the childRect also gets destroyed but is not removed from the scene. You can see it in action in the video I shared along with the minimal example.

      It's my understanding that once the parent of a QObject changes, its life time is bound to its new parent. Although, the context in which the childRect is created is different from the context of its new parentRect. I wonder If that has something to do with it. I could not find related information in the documentation for QQmlContext.

      Attachments

        1. QTBUG.mov
          5.26 MB
        2. QTBUG.zip
          27 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            furkanzmc Furkan Üzümcü
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes