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. Dynamic object destroy
Qt 6.11 is out! See what's new in the release blog

Dynamic object destroy

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 1.1k 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.
  • T Offline
    T Offline
    The Smiling Mickey
    wrote on last edited by
    #1

    Hey,

    I have a button which creates a box dynamically which I've done like the Qt Document: Dynamic QML Object Creation from JavaScript suggests.

    function createObject() {
            var comp = Qt.createComponent("Box.qml")
            var box = comp.createObject(parent)
        }
    

    Now, I need function which removes the created object but I am unable to access it. I can't figure out how to do that based on that Qt document and I haven't found any other references either.

    So could somebody please let me know, how this can be achieved?

    JonBJ 1 Reply Last reply
    0
    • T The Smiling Mickey

      Hey,

      I have a button which creates a box dynamically which I've done like the Qt Document: Dynamic QML Object Creation from JavaScript suggests.

      function createObject() {
              var comp = Qt.createComponent("Box.qml")
              var box = comp.createObject(parent)
          }
      

      Now, I need function which removes the created object but I am unable to access it. I can't figure out how to do that based on that Qt document and I haven't found any other references either.

      So could somebody please let me know, how this can be achieved?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @The-Smiling-Mickey
      You mean like in http://doc.qt.io/qt-5/qtqml-javascript-dynamicobjectcreation.html (same page as you mention), section Deleting Objects Dynamically , the destroy() method?

      1 Reply Last reply
      1
      • T Offline
        T Offline
        The Smiling Mickey
        wrote on last edited by
        #3

        Right, I thought twice about mentioning the destroy() method but I thought it was obvious that it needs to be used.

        The question is how I need to use it outside the function, I wrote, so it actually removes what it needs to?

        T 1 Reply Last reply
        0
        • T The Smiling Mickey

          Right, I thought twice about mentioning the destroy() method but I thought it was obvious that it needs to be used.

          The question is how I need to use it outside the function, I wrote, so it actually removes what it needs to?

          T Offline
          T Offline
          The Smiling Mickey
          wrote on last edited by
          #4

          Well, thanks for all the help I guess.

          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