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 6215229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:01:05+00:00 2026-05-24T07:01:05+00:00

Im writing a c++ qt application. In one part I’m creating a QTreeWidget. The

  • 0

Im writing a c++ qt application. In one part I’m creating a QTreeWidget. The user has all possibilities to create and delete entries in that tree.
So when the user creates a item he will call a function which then itself calls:

QTreeWidgetItem* newItem = new QTreeWidgetItem();

When the user later decides to delete the entry, he calls a function which then itself will call:

QTreeWidgetItem* curItem = _ui->qTreeWidget->currentItem();
QTreeWidgetItem* parent = curItem->parent();
parent->removeChild(curItem);

The question that erases for me is now: what about the memory this item occupied? What The Qt 4.7 doc says to removeChild is the following:

void QTreeWidgetItem::removeChild ( QTreeWidgetItem * child )
Removes the given item indicated by child. The removed item will not be deleted.

So how do i delete a child?

Thanks a lot in advance!
Donny

  • 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-24T07:01:06+00:00Added an answer on May 24, 2026 at 7:01 am

    How about

    delete curItem;
    

    ?

    According to the documentation, the destructor will remove the item from the tree in which it is included, so I think you don’t even need to perform the removeChild beforehand.

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

Sidebar

Related Questions

I'm writing a WinForms application and one of the tabs in my TabControl has
I'm writing a CMS application in PHP and one of the requirements is that
I'm writing a J2SE desktop application that requires one of its components to be
I'm writing a J2ME application. One of the pieces is something that polls the
I am writing an application which tests email addresses, for one part of this
I am writing a small application using Rails 3. In one part of it
I'm writing an small software that will be part of an existing application which
Part of a real estate application I'm writing will allow a user to subscribe
I am starting the process of writing an application, one part of which is
I am writing a web application that will allow a user to browse to

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.