×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    231

    Question Deleting QObject instances

    Hi,

    I have an instance of QPushButton into QWidget window. For example:

    in the .h file
    Code:
    ...
    QPushButton 			*myQPushButton;
    ...
    in the .cpp file:
    Code:
    myQPushButton = new QPushButton(this);
    
    ...
    
    myWindow::~myWindow()
        {
        if (myQPushButton)
            {
            delete myQPushButton;
            myQPushButton = NULL;
            }
        }
    It is necessary to call delete for myQPushButton instance in the destructor?

    Regards.

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Deleting QObject instances

    When you created the QPushButton you specified a "parent". When you do this, the lifetime of the "child" is tied to the lifetime of the "parent" -- there's no need to explicitly delete the "child".

Similar Threads

  1. Replies: 8
    Last Post: 2010-09-29, 08:58
  2. Deleting CEikEdwin instances
    By rinyogi03 in forum Symbian User Interface
    Replies: 1
    Last Post: 2009-02-16, 19:02

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •