Qt Forum

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

    Qt Academy Launch in California!

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

    QML and Qt Quick
    dynamic qml createqmlobject
    3
    6
    518
    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.
    • Crawl.W
      Crawl.W last edited by 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.

      Gojir4 1 Reply Last reply Reply Quote 0
      • Gojir4
        Gojir4 @Crawl.W last edited by

        @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.W 1 Reply Last reply Reply Quote 0
        • Crawl.W
          Crawl.W @Gojir4 last edited by Crawl.W

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

          Gojir4 1 Reply Last reply Reply Quote 0
          • Gojir4
            Gojir4 @Crawl.W last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • F
              FKosmale last edited by 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.W 1 Reply Last reply Reply Quote 2
              • Crawl.W
                Crawl.W @FKosmale last edited by Crawl.W

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • First post
                  Last post