About the life cycle of the Item created dynamicly by the Loader
-
Hi,
I have a problem about the life cycle of the Item created dynamicly by the Loader.
In my UI, there is buttonA. and When I clicked the buttonA ,and it will use the Loader to load a qml file(Page), and then push it in to
a PageStack.And there is a buttonB, when I clicked the buttonB, it will pop the item(Page) in the PageStack. Then the Item(Page) that pop out ot the PageStack will destroy automaticly? or it will exist forever until its parent destroy?
How can I manage the Item created dynamicly(random) ?
-
If you are pushing a components on to the stack, it will be destroyed as soon as its popped out. So, in your case as you are pushing a qml file ( nothing but a component, its destroyed as soon as you do a pop)
http://doc.qt.nokia.com/qt-components-symbian-1.0/qt-components-pages-and-navigation-overview.html
for more information.
-
Instead of using Loader, you can use
@
pageStack.push(Qt.resolvedUrl("FilePage.qml"))
@bq. When you pop the page object off the stack, the stack destroys the page object and you no longer have access to it.
-
Thanks.
But my situaton is not that simple. Every new Page created dynamicly will have its own C++ model. And the C++ modle will provide data for it.
If I just use push the componet or pageStack.push(Qt.resolvedUrl("FilePage.qml"))
I will lost control to the Page I pushed. -
[quote author="task_struct" date="1312971271"]Instead of using Loader, you can use
@
pageStack.push(Qt.resolvedUrl("FilePage.qml"))
@bq. When you pop the page object off the stack, the stack destroys the page object and you no longer have access to it.
- "PageStack":http://doc.qt.nokia.com/qt-components-symbian-1.0/qml-pagestack.html#pushing-a-qml-component-page[/quote]
Correct me if I am wrong but if you do that you loose the ability to listen to signal from the loaded page. Using a Loader + a Connections element allow to bind to event from the page.
[quote author="Vijay Bhaska Reddy" date="1312969805"]If you are pushing a components on to the stack, it will be destroyed as soon as its popped out. So, in your case as you are pushing a qml file ( nothing but a component, its destroyed as soon as you do a pop)
http://doc.qt.nokia.com/qt-components-symbian-1.0/qt-components-pages-and-navigation-overview.html
for more information.[/quote]
Again, correct me if I am wrong but if you use a Loader (like the OP was asking) the page is not a component but an item, so it is not destroyed when the page is poped of the stack. Instead it is re parented to its original parent, the Loader in our case.