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 terminate or hide a qml using loader
QtWS25 Last Chance

How to terminate or hide a qml using loader

Scheduled Pinned Locked Moved QML and Qt Quick
9 Posts 4 Posters 4.9k Views
  • 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.
  • J Offline
    J Offline
    jr_jags
    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
      • J Offline
        J Offline
        jr_jags
        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
          • Z Offline
            Z Offline
            ZapB
            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.

            Nokia Certified Qt Specialist
            Interested in hearing about Qt related work

            1 Reply Last reply
            0
            • J Offline
              J Offline
              jr_jags
              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
              • Z Offline
                Z Offline
                ZapB
                wrote on last edited by
                #7

                Something like this should do it:

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

                ...

                MouseArea {
                onClicked: myLoader.source = undefined
                }
                @

                Nokia Certified Qt Specialist
                Interested in hearing about Qt related work

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  jr_jags
                  wrote on last edited by
                  #8

                  Thank you sir, ill try it in my project

                  1 Reply Last reply
                  0
                  • N Offline
                    N Offline
                    nhojyer07
                    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 Extensions
                    • Unsolved