Results 1 to 5 of 5

Thread: Closing all of the mainWindow's child dialogs

  1. #1
    Join Date
    Aug 2008
    Posts
    132
    Thanks
    23
    Thanked 3 Times in 3 Posts

    Default Closing all of the mainWindow's child dialogs

    Hi

    I'm trying to find a way to delete all of the opened child windows (separate dialogs) of my mainWindow. Is this possible. I've looked at the destroy function of the QWidget base class, but it seems like this will destroy all the qwidgets of the mainWindow as well. Is there an easy way to do this? Or is it necessary to do some sort of recursive run through all the children?

    Thanks
    Jaco

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Closing all of the mainWindow's child dialogs

    All you need to do is to pass the main window as parent to the dialogs. When the main window is destructed (Qt::WA_DeleteOnClose might become handy), all its children are automatically destructed as well.
    J-P Nurmi

  3. #3
    Join Date
    Aug 2008
    Posts
    132
    Thanks
    23
    Thanked 3 Times in 3 Posts

    Default Re: Closing all of the mainWindow's child dialogs

    Thanks for the reply.

    I'm aware of the solution you posted. However I want to be able to close all the opened windows without having to close the main window.

    Thanks
    Jaco

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Closing all of the mainWindow's child dialogs

    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    JPNaude (2nd October 2008)

  6. #5
    Join Date
    Aug 2008
    Posts
    132
    Thanks
    23
    Thanked 3 Times in 3 Posts

    Default Re: Closing all of the mainWindow's child dialogs

    Thank you very much. This is exactly what I was looking for.

    Jaco

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.