Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 661407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:15:49+00:00 2026-05-13T23:15:49+00:00

Sorry for the dumb question, but I’m working with Qt and C++ for the

  • 0

Sorry for the dumb question, but I’m working with Qt and C++ for the first time, and working through the tutorial and some samples.

One thing that was mentioned was that Qt stuff doesn’t need to be explicitly deleted. So, main question, does this also apply to collections of Qt stuff? Like say I want a dynamic number of MyWidgets, so I keep a vector or whatever of them. Are they still taken care of for me?

As a side question, what is going on to make it so I don’t have to worry about destructors?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:15:49+00:00Added an answer on May 13, 2026 at 11:15 pm

    Qt has an interesting object model for sure. When I first started it made me uneasy that there were so many new Foo calls and no deletes.

    http://qt.nokia.com/doc/4.6/object.html Is a good place to start reading up on the object model.

    Things of interest:
    QObject subclasses have their assignment and copy-ctor methods disabled. The chain of object child-parents is maintained internally by QObject.

    Generally when instantiating a QObject subclass (if you don’t plan on managing its pointer yourself) you will provide another QObject pointer as the parent. This ‘parent’ then takes over the management of the child you just made. You can call setParent() on a QObject to change who “owns” it. There are very few methods in Qt that will change the parent of an object, and they all explicitly state that they do in the docs.

    So to answer your specific question: it depends on how you made all of your MyWidget instances.

    If you made each one with a parent, then no you don’t have to delete them. The parent will delete them when it gets deleted.

    If you’re keeping a QList<MyWidget*> collection of them, and you didn’t give them a parent, then you should delete them yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

first of all, sorry if that question is dumb but I´m a total newbie
Sorry if this is a dumb question but im creating a filter class that
Sorry for the dumb question, but string handling in xsl 1.0 is not one
First of all sorry if it's a dumb question (and surely it is), but
Sorry for maybe dumb question, but i have HUGE problem with one case when
This might be a dumb question. Sorry if it is. But Im working on
Sorry if this is a dumb question, but it is possible to store, and
Sorry if it is a dumb question, but the issue is quite straight forward.
Not a full-time jQuery nor Javascript dev so sorry if dumb question. I think
Sorry for the dumb question, but... I'm moving from VB to C# and this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.