Results 1 to 5 of 5

Thread: exit(0) does not call closeEvent

  1. #1
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default exit(0) does not call closeEvent

    Hi friends!

    When the user closes my app (pressing window X), closeEvent tests if you want to save document, but if user uses menus, my code calls exit(0) but closeEvent is not called!

    Do you know how I should close my app from menus in order to call closeEvent before exiting?

    Thanks a lot for your help.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: exit(0) does not call closeEvent


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

    ricardo (24th June 2009)

  4. #3
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: exit(0) does not call closeEvent

    Quote Originally Posted by Lykurg View Post
    None of them work, both bypass closeEvent. But I realised close() is what I was looking for.

    Thanks anyway.

  5. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: exit(0) does not call closeEvent

    Quote Originally Posted by ricardo View Post
    None of them work, both bypass closeEvent.
    Right, my brain... sorry.

  6. #5
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: exit(0) does not call closeEvent

    just connect your exit action triggered() signal with main window's close() slot. You can even do it with Designer.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

Similar Threads

  1. QSettings and closeEvent()
    By vito49 in forum Newbie
    Replies: 2
    Last Post: 13th October 2008, 16:18
  2. what if qthread call same slot at the same time?
    By zl2k in forum Qt Programming
    Replies: 2
    Last Post: 11th September 2008, 09:58
  3. call the other dialog through dialog
    By narumi in forum Qt Programming
    Replies: 2
    Last Post: 3rd September 2008, 09:30
  4. how to call parent widget's event ?
    By rajeshs in forum Qt Programming
    Replies: 1
    Last Post: 20th December 2007, 12:39
  5. why cant i call setGeometry
    By freegnu in forum Qt Programming
    Replies: 1
    Last Post: 14th June 2006, 04:59

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.