Results 1 to 2 of 2

Thread: where QMdiSubWindow destructor should be called

  1. #1
    Join Date
    Jan 2013
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default where QMdiSubWindow destructor should be called

    Hi! I'm developing a standard MDI application and I don't know where should I call a MDI child window destructor.

    Right now, I'm not calling it anywhere. My child window destructor prints some output do std::cout (some test output). When I close a child window I can see nothing in the Qt Creator console. But when I close the whole application (the QMainWindow), all console outputs are printed (terminating main window terminates all children).

    I guess I should call the child destructor manually somewhere, but don't know where (maybe should use connect function anyhow)? Thanks for any help.

  2. #2
    Join Date
    Jan 2013
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: where QMdiSubWindow destructor should be called

    I found a way to destroy the window when the close ("X") button is clicked:

    Qt Code:
    1. ChildWindow *child = new ChildWindow(ui->mdiArea);
    2. child->setAttribute(Qt::WA_DeleteOnClose);
    3. childWindows.append(child);
    4. child->show();
    To copy to clipboard, switch view to plain text mode 

    The second line does the job. The solution is based on http://doc.qt.io/qt-4.8/qmdiarea.html#addSubWindow

Similar Threads

  1. Destructor not being called
    By vieraci in forum Qt Programming
    Replies: 12
    Last Post: 25th January 2012, 15:06
  2. Destructor not called
    By satoshi in forum General Programming
    Replies: 2
    Last Post: 23rd April 2010, 13:55
  3. Weird problems when destructor is called
    By cyberboy in forum Qt Programming
    Replies: 9
    Last Post: 21st October 2008, 13:59
  4. Destructor in QT
    By hgedek in forum Newbie
    Replies: 1
    Last Post: 18th September 2007, 10:54
  5. QMap destructor bug
    By Ruud in forum Qt Programming
    Replies: 6
    Last Post: 8th April 2006, 09:08

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.