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. Qt classes parent child relationship.

Qt classes parent child relationship.

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.6k 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.
  • musimbateM Offline
    musimbateM Offline
    musimbate
    wrote on last edited by
    #1

    Hi all,

    I was designing some classes for my application and wondered if the parent /child relationship of Qt can allow me to do something like this:
    @
    QObject * fatherObject=new QObject(0);

    //I dynamically create a memory space.The parent should take care of cleaning up for this memory space even after we loose access to it by assigning pmClass pointer to another dynamically allocated space.
    Qclass * pmClass= new QClass(fatherObject);

    pmClass=new QClass(fatherObject);

    .........................................

    //When the parent dies he dies with all his children .
    delete fatherObject;

    @

    NOTE:This is not inheritance it is simple parent /child relationship .

    Thanks for your input.

    Why join the navy if you can be a pirate?-Steve Jobs

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on last edited by
      #2

      Yes, this will work as you expected.

      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