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. How to close a qml loaded by LOADER in its page.
Forum Updated to NodeBB v4.3 + New Features

How to close a qml loaded by LOADER in its page.

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 2 Posters 4.6k 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.
  • M Offline
    M Offline
    mageLuzdia
    wrote on last edited by
    #1

    hi guys,i got a problem.
    i set a main qml for main page,there are several buttons on it ,when clicking it ,a child page is loaded by loader element ,but how to close it. My plan is setting a BACK button on the child page,when clicking it ,the child page will be close .how to do it ?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Please read the "documentation":http://qt-project.org/doc/qt-5.1/qtquick/qml-qtquick2-loader.html#source-prop, it clearly states:
      [quote]To unload the currently loaded object, set this property to an empty string, or set sourceComponent to undefined. Setting source to a new URL will also cause the item created by the previous URL to be unloaded.[/quote]

      (Z(:^

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mageLuzdia
        wrote on last edited by
        #3

        [quote author="sierdzio" date="1377247986"]Please read the "documentation":http://qt-project.org/doc/qt-5.1/qtquick/qml-qtquick2-loader.html#source-prop, it clearly states:
        [quote]To unload the currently loaded object, set this property to an empty string, or set sourceComponent to undefined. Setting source to a new URL will also cause the item created by the previous URL to be unloaded.[/quote][/quote]
        YES , i read it yet .but the "unload“ which it said is to unload the source in the main page. now my child page is full of my screen.and i wanna click the BACK button on the child page to close it ...so i am confused:(

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          So, the Back button is a child of the page that is loaded inside the Loader?

          You can send a signal to your main view to notify it that the page needs to be closed. This is a clean and flexible solution, allowing you to react nicely in the main view, and it will be easy to extend later. Passing singals to and from Loaders is described in the documentation.

          Other possibility would be to clean "source" from inside your child page: you can get to Loader using parent-child hierarchy:
          @
          Loader {
          source: "kid.qml"
          }

          // kid:
          Item {
          id: root
          YourButton {
          onClicked: root.parent.source = ""; // or root.parent.parent.source = ""
          }
          }
          @

          I won't say it's a good solution, though.

          (Z(:^

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mageLuzdia
            wrote on last edited by
            #5

            [quote author="sierdzio" date="1377248767"]So, the Back button is a child of the page that is loaded inside the Loader?

            You can send a signal to your main view to notify it that the page needs to be closed. This is a clean and flexible solution, allowing you to react nicely in the main view, and it will be easy to extend later. Passing singals to and from Loaders is described in the documentation.

            Other possibility would be to clean "source" from inside your child page: you can get to Loader using parent-child hierarchy:
            @
            Loader {
            source: "kid.qml"
            }

            // kid:
            Item {
            id: root
            YourButton {
            onClicked: root.parent.source = ""; // or root.parent.parent.source = ""
            }
            }
            @

            I won't say it's a good solution, though.[/quote]
            i'll try it ...and really very thank u because u r so enthusiastic! and wanna communicate more :)

            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