Results 1 to 2 of 2

Thread: Pro's and con's of using close event instead of destructor

  1. #1
    Join Date
    Aug 2006
    Location
    The Netherlands
    Posts
    64
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Pro's and con's of using close event instead of destructor

    My program needs to save some settings to a file when a user closes or exits the program.

    Question, what is the best approach, calling the function that saves the settings from the destructor of QMainWindow or call it from closeEvent(QCloseEvent *event) ?

    Another question, which function will be called first when a user quit the program, the destructor or the close event?

  2. #2
    Join Date
    Aug 2008
    Location
    Algarve, Portugal
    Posts
    287
    Thanks
    23
    Thanked 31 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Pro's and con's of using close event instead of destructor

    The close event will be called first.
    I believe this is the best place because you can ask the user to save or not the data and you can allow wthe user not to close the program, with the event->ignore();
    Check the main application example
    __________________________________________________
    My projects: calculator MathGraphica ; SuperEpicMegaHero game ; GooglePlay ; bitbucket ; github
    Like my projects ? Buy me a kofi

  3. The following user says thank you to john_god for this useful post:

    Teuniz (27th November 2009)

Similar Threads

  1. Style Sheets & Pros and Cons on Qt.
    By BingoMaster in forum Newbie
    Replies: 1
    Last Post: 26th September 2009, 09:13

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.