Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. About the life cycle of the Item created dynamicly by the Loader

About the life cycle of the Item created dynamicly by the Loader

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 4 Posters 3.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    harlentan
    wrote on last edited by
    #1

    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) ?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      thisisbhaskar
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        task_struct
        wrote on last edited by
        #3

        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

        "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

        • Linu...
        1 Reply Last reply
        0
        • H Offline
          H Offline
          harlentan
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • R Offline
            R Offline
            remy_david
            wrote on last edited by
            #5

            [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.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved