Results 1 to 4 of 4

Thread: Why doesn't my dialog window close when the mainwindow is closed?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: Why doesn't my dialog window close when the mainwindow is closed?

    Try to set attribute Qt::WA_DeleteOnClose for the main window. This assures that the main window is deleted upon closing and so the dialog should be destructed also.
    J-P Nurmi

  2. The following 2 users say thank you to jpn for this useful post:

    alr1970 (20th October 2009), pir (23rd July 2006)

  3. #2
    Join Date
    May 2006
    Location
    Stockholm, Sweden
    Posts
    81
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Why doesn't my dialog window close when the mainwindow is closed?

    I thought that the MainWindow was set to this as default. Thanks, I will try that. It's good to know, but I solved the problem with implementing the closeEvent() and close down all dialogs there. I needed to save the state of the dialogs anyway...

    But is the parent child relation ok?
    Because I'm a bit unsure about how the destruction of the widgets work. Can't find it explained in detail on the homepage. According to what I've understaned , is the children automatically destructed when the parent is destructed. But what about orphins? Do I need to destroy them myself, or does Qt's main loop take care of this when I close down the Qt session?

    thanks
    pir

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Why doesn't my dialog window close when the mainwindow is closed?

    Quote Originally Posted by pir
    Because I'm a bit unsure about how the destruction of the widgets work.
    If a QObject is destructed, it destroys all its children each of which in turn destroy all its children, etc.

    But what about orphins? Do I need to destroy them myself, or does Qt's main loop take care of this when I close down the Qt session?
    You have to destroy them yourself. Qt doesn't do anything *magic*, it's just a C++ library.

Similar Threads

  1. Replies: 1
    Last Post: 1st June 2006, 12:46
  2. dialog box
    By Bahar in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2006, 14:52

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.