[Interest] Dynamically created item destroyed with original parent despite reparenting

Elvis Stansvik elvstone at gmail.com
Sun Dec 20 16:10:55 CET 2015


2015-12-20 16:05 GMT+01:00 Personal Gmail <siamak.rahimi.motem at gmail.com>:
> Hi Elvis ,
> Can we destroy() old parent which is not a component ? In other words, Is
> not the destroy only for component created dynamically ?
> I think oldParent.destory is problematic.

Aha, now I see what you mean. I've never actually used QML myself, and
didn't know this (and that setting transparency to 0 is actually the
recommended way to remove it from the visual scene hierarchy).

But I think you're right, and that Peter should probably do that
instead, or otherwise make sure his old parent is created dynamically.

In any case, I tried

newParent.data.push(target);

and it seems to work, the blue rect remains. But I realize now that
.push is not documented in Qt 5 documentation
(http://doc.qt.io/qt-5/qml-list.html) so perhaps this is not
guaranteed to be supported. In the old 4.x docs, it says there are
limitations on .push (it'll only create a new list, not modify an
existing, but don't know if this holds for 5.x).

Elvis

>
> On 20 Dec 2015, at 17:02, Elvis Stansvik <elvstone at gmail.com> wrote:
>
> Elvis
>
>



More information about the Interest mailing list