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

Peter Klosowski kloffy at gmail.com
Sun Dec 20 16:39:57 CET 2015


Unfortunately, the solution Elvis provided does not work for me. Instead, I
get the following error:

TypeError: Property 'push' of object [object Object] is not a function

Of course, that means the blue rectangle stays on the screen, but only
because the code after the error never gets executed (i.e. oldParent never
gets destroyed).

Nevertheless, I believe this would be the right track, if it is possible at
all.

Best regards,
kloffy


On Mon, Dec 21, 2015 at 1:28 AM, Peter Klosowski <kloffy at gmail.com> wrote:

> Thank you all for your suggestions. This is an artificial example to
> illustrate the behavior that I am having problems with. I could also
> dynamically create the parent, that is not of relevance to my problem.
>
> On the other hand, the information that Elvis provided about the
> distinction between visual parent and QObject parents seems to hit the nail
> on the head. I will test and report back!
>
> Best regards,
> koffy
>
> On Mon, Dec 21, 2015 at 1:10 AM, Elvis Stansvik <elvstone at gmail.com>
> wrote:
>
>> 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
>> >
>> >
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20151221/8afa2b60/attachment.html>


More information about the Interest mailing list