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. Whether returned object from Qt.createComponent needs to be destroyed?

Whether returned object from Qt.createComponent needs to be destroyed?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
dynamic qmlcreateqmlobject
6 Posts 3 Posters 1.0k 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.
  • Crawl.WC Offline
    Crawl.WC Offline
    Crawl.W
    wrote on last edited by Crawl.W
    #1
    var component = Qt.createComponent("SplashScreen.qml");
    var obj = component.createObject(parent);
     if(obj === null)
     {
          obj.finished.connect(showHomePage);
     }
    

    In the official example, no destroy.

    Gojir4G 1 Reply Last reply
    0
    • Crawl.WC Crawl.W
      var component = Qt.createComponent("SplashScreen.qml");
      var obj = component.createObject(parent);
       if(obj === null)
       {
            obj.finished.connect(showHomePage);
       }
      

      In the official example, no destroy.

      Gojir4G Offline
      Gojir4G Offline
      Gojir4
      wrote on last edited by
      #2

      @crawl-w Hi,

      Using destroy(). The doc of createObject() say:

      Dynamically created instances can be deleted with the destroy() method. See Dynamic QML Object Creation from JavaScript for more information.

      Crawl.WC 1 Reply Last reply
      0
      • Gojir4G Gojir4

        @crawl-w Hi,

        Using destroy(). The doc of createObject() say:

        Dynamically created instances can be deleted with the destroy() method. See Dynamic QML Object Creation from JavaScript for more information.

        Crawl.WC Offline
        Crawl.WC Offline
        Crawl.W
        wrote on last edited by Crawl.W
        #3

        @gojir4 What you are saying is obj not component in the example code. obj is instance of component.

        Gojir4G 1 Reply Last reply
        0
        • Crawl.WC Crawl.W

          @gojir4 What you are saying is obj not component in the example code. obj is instance of component.

          Gojir4G Offline
          Gojir4G Offline
          Gojir4
          wrote on last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • F Offline
            F Offline
            FKosmale
            wrote on last edited by FKosmale
            #5

            The JavaScript engine will indeed take ownership of the object created by Qt.createComponentObject. This is not documented specifically because in general, any object returned by a JavaScript function is normally managed by the garbage collector.

            Crawl.WC 1 Reply Last reply
            2
            • F FKosmale

              The JavaScript engine will indeed take ownership of the object created by Qt.createComponentObject. This is not documented specifically because in general, any object returned by a JavaScript function is normally managed by the garbage collector.

              Crawl.WC Offline
              Crawl.WC Offline
              Crawl.W
              wrote on last edited by Crawl.W
              #6
              This post is deleted!
              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