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. When QVXYModelMapper is destroyed
Forum Updated to NodeBB v4.3 + New Features

When QVXYModelMapper is destroyed

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

    I connected chart and tableview in model.
    QVXYModelMapper is also associated with the model.
    The question here is when does it end?

    When the model disappears, all connected objects are destroyed?
    Do I have to delete them separately?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      QVXYModelMapper is also associated with the model.
      The question here is when does it end?

      Object lifetimes are governed by C++ rules.
      If your QVXYModelMapper is on the stack then it is destroyed when it goes out of scope.
      If it is on the heap, i.e. created with new, then it is destroyed when delete is called.

      If you delete a QObject then all its child QObjects, i.e. those created with a parent, will also be deleted. Your QVXYModelMapper is a QObject and may have a parent, or may not.
      See Object Trees

      When the model disappears, all connected objects are destroyed?

      No. If you delete a QObject it stops sending signals and anything previous connected is no longer connected. The receiving objects continue to exist (unless they were children of the deleted QObject).

      Do I have to delete them separately?

      You are responsible for management of object lifetime. You can directly delete objects, use smart pointers, or use the QObject parent-child mechanism.

      1 Reply Last reply
      2

      • Login

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