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?
Forum Updated to NodeBB v4.3 + New Features

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.1k 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.
  • C Offline
    C Offline
    Crawl.W
    wrote on 10 Sept 2019, 13:25 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.

    G 1 Reply Last reply 10 Sept 2019, 13:41
    0
    • C Crawl.W
      10 Sept 2019, 13:25
      var component = Qt.createComponent("SplashScreen.qml");
      var obj = component.createObject(parent);
       if(obj === null)
       {
            obj.finished.connect(showHomePage);
       }
      

      In the official example, no destroy.

      G Offline
      G Offline
      Gojir4
      wrote on 10 Sept 2019, 13:41 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.

      C 1 Reply Last reply 11 Sept 2019, 01:55
      0
      • G Gojir4
        10 Sept 2019, 13:41

        @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.

        C Offline
        C Offline
        Crawl.W
        wrote on 11 Sept 2019, 01:55 last edited by Crawl.W 9 Nov 2019, 01:56
        #3

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

        G 1 Reply Last reply 11 Sept 2019, 16:44
        0
        • C Crawl.W
          11 Sept 2019, 01:55

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

          G Offline
          G Offline
          Gojir4
          wrote on 11 Sept 2019, 16:44 last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • F Offline
            F Offline
            FKosmale
            wrote on 11 Sept 2019, 18:34 last edited by FKosmale 9 Nov 2019, 20:54
            #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.

            C 1 Reply Last reply 12 Sept 2019, 01:38
            2
            • F FKosmale
              11 Sept 2019, 18:34

              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.

              C Offline
              C Offline
              Crawl.W
              wrote on 12 Sept 2019, 01:38 last edited by Crawl.W
              #6
              This post is deleted!
              1 Reply Last reply
              0

              1/6

              10 Sept 2019, 13:25

              • Login

              • Login or register to search.
              1 out of 6
              • First post
                1/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved