Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Automatic deletion of QObjects
Forum Update on Monday, May 27th 2025

Automatic deletion of QObjects

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 451 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.
  • ModelTechM Offline
    ModelTechM Offline
    ModelTech
    wrote on last edited by
    #1

    In my application, I am currently doing the deletion of QObjects myself (too much of traditional C++ history perhaps...). I would however like to introduce undo/redo functionality in my application and from the undo example that comes with Qt (http://doc.qt.io/qt-5/qtwidgets-tools-undo-example.html), I understand that the QObjects (in this case diagram items) are not really destroyed but only removed from the scene on a delete action by the user. By keeping the diagram item in memory, the action can be undone. As I intend to limit the undo stack size, I would like to have the objects destroyed at the moment that the stack size limit is reached. So, my question is actually: will QObjects be destroyed automatically if there are no references to them anymore (with or without having a parent)?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      If the objects don't have any parent then no.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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