[Qt-qml] reparent on destruction
Pekka.E.Jokela at nokia.com
Pekka.E.Jokela at nokia.com
Tue Sep 20 07:44:57 CEST 2011
Hi,
Is there a way to re-parent a child item on the destruction?
I would like to re-use a QML item in several views, because the item consumes a lot of memory and takes time to initialize. When a view becomes active, the item is re-parented to that view. This way, the transformations and z-order of the re-cycled item matches the view. Now the problem arises when the active view is destroyed at run-time. We would need to re-parent the recycled item to the next visible view on the view stack. How this can be done?
View {
Component.onDestruction {
recycledChild.parent = newView
}
}
Problem with this approach is that the recycledChild is, at the time of the deletion, a child of the deleted view and the destruction order is undefined i.e. the child items are most likely destroyed already.
One option is implement the View in c++ and re-parent in the destructor, but then we cannot "derive" from QML items like Page element from qt-components.
-Pekka
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20110920/4582bd4a/attachment.html
More information about the Qt-qml
mailing list