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. C++ object destructor is not invoked when QML item is destroyed

C++ object destructor is not invoked when QML item is destroyed

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 2.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.
  • M Offline
    M Offline
    maksim1979
    wrote on 2 Sept 2014, 07:59 last edited by
    #1

    Hello,

    I have a subclass of QQuickItem that I use in a qml view. I've noticed that when I destroy the qml view, all qml-based children are destroyed but for c++ objects it's not a case. When I close the whole application, destructors for these objects are invoked. Is it possible to do something with that?

    Thanks a lot,
    Maksim

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dasRicardo
      wrote on 2 Sept 2014, 15:44 last edited by
      #2

      Hmm, you can call delete for the objects in the destructor of your QQuickItem

      **Sorry for my english :)

      PLEASE ADD [SOLVED] TO YOUR THREAD TITLE IF IT'S SOLVED.**

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maksim1979
        wrote on 2 Sept 2014, 16:41 last edited by
        #3

        Ricardo, frankly I didn't get that. I have a class lets say MyNiceChart that extends QQuickItem. I registerd this new type and use it in qml

        @
        Rectangle {
        id : somePanel

         MyNiceChart {
         }
        
         Rectangle {
              id : antoherItem
         }     
        

        }
        @

        So when I don't need somePanel anymore I destroy it : somePanel.destroy() and I noticed that
        anotherItem will be destroyed as well during this operation but destructor of MyNiceChart is not invoked. Do you suggest to invoke MyNiceChart destructor manually?

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dasRicardo
          wrote on 3 Sept 2014, 08:01 last edited by
          #4

          Take a look @ "this...":http://comments.gmane.org/gmane.comp.lib.qt.user/7508

          **Sorry for my english :)

          PLEASE ADD [SOLVED] TO YOUR THREAD TITLE IF IT'S SOLVED.**

          1 Reply Last reply
          0

          2/4

          2 Sept 2014, 15:44

          • Login

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