Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to terminate or hide a qml using loader
Qt 6.12 LTS is out! See what's new in the release blog

How to terminate or hide a qml using loader

Scheduled Pinned Locked Moved QML and Qt Quick
9 Posts 4 Posters 6.0k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    is there a way how to terminate or hide an opened qml, just like in other PL's, like in visual basic, there are commands wherein a qml is just like a form, that is when a button is clicked a new form will be shown and the previous form will be hide or will be close, just like the Me.hide command,

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mohsen
      wrote on last edited by
      #2

      QML is not like a VB application that you can open or hide a window. you can hide any object in qml using .visible=false
      your windows can be something like components in QML.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        ahh ok, just checking if theres a way on terminating a qml just like a vb application :),

        Thank you sir

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mohsen
          wrote on last edited by
          #4

          for closing the whole application (+QML viewer) you may use Qt.quit()

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            If you use a Loader item then you can unload the item by setting the Loader's source property to undefined. This will free the allocated resources for that item.

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              how can i make the source undefined? can you please give me a sample code for that line?

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                Something like this should do it:

                @
                Loader {
                id: myLoader
                source: "MyComponent.qml"
                }

                ...

                MouseArea {
                onClicked: myLoader.source = undefined
                }
                @

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #8

                  Thank you sir, ill try it in my project

                  1 Reply Last reply
                  0
                  • ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #9

                    you can also use

                    @myLoader.source = ""@

                    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
                    • Unsolved