Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Component Destruction

    QML and Qt Quick
    2
    3
    195
    Loading More Posts
    • 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.
    • G
      Gabriidc last edited by VRonin

      Hi,

      When Load a component using Loader I can delete the component when I dont need more in the application changing the value of property source to ""

      Example:

      //Component.qml
      Component
      {
      Rectangke{....}
      }
      
      //Main.qml
      Window
      {
         Button{
                text: "Load"
                onClicked: loader.source = "Component.qml"
          }
         Button{
                text: "Close"
                onClicked: loader.source = ""
          }
         Loader{
               id: loader
         }
      }
      

      My problem occurs when instead of use Loader I use as show bellow:

      //Main.qml
      Window
      {  
             Component
             {
                .....
             }
      } 
      

      Using this option I dont know how can I load and delete the component when I need.

      1 Reply Last reply Reply Quote 0
      • IntruderExcluder
        IntruderExcluder last edited by

        You can create it dynamically by calling createObject and destroy when needed via destroy. More info can be found here.

        G 1 Reply Last reply Reply Quote 0
        • G
          Gabriidc @IntruderExcluder last edited by

          @IntruderExcluder Thank you so much !

          1 Reply Last reply Reply Quote 0
          • First post
            Last post