Results 1 to 4 of 4

Thread: signals when closing QMainWindow

  1. #1
    Join Date
    Jun 2008
    Posts
    18
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Question signals when closing QMainWindow

    Does anybody know what signal QMainWindow sends out when you close it by the following methods:

    1. double click the upper-left corner of a QMainWindow, or
    2. left click the upper-left corner of a QMainWindow, then select Close()

    I was unable to catch destroyed() signal, I didn't get any closeEvent as well.

    The reason for my question is when my main window (QMainWindow) is closed though above method, other windows( generated from main window, but not necessarily child of QMainWindow) are still running. What I want is every window closed when QMainWindow is closed.

    Thanks in advance!

  2. #2
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: signals when closing QMainWindow

    One solution for what you want is,

    Make the window/widget to modality, such that users cannot able to close the mainwindow until you close the other.

    Check Qt::WindowModality.

    And also,
    I have implemented in my application, when you hit,

    1. double click the upper-left corner of a QMainWindow, or
    2. left click the upper-left corner of a QMainWindow, then select Close()

    It calls closeEvent(...). you need to relook into its implementation.

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

    qmonkey (7th January 2010)

  4. #3
    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: signals when closing QMainWindow

    Just reimplement closeEvent() in you QMainWindow subclass and close your widgets there.
    There is example code in QWidget::closeEvent() documentation,
    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.

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

    qmonkey (7th January 2010), zeFree (6th December 2012)

  6. #4
    Join Date
    Jun 2008
    Posts
    18
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: signals when closing QMainWindow

    Thank you all for the reply!

    Reimplement closeEvent() solved the problem.

Similar Threads

  1. How to handle 2 QmainWindow closing problems
    By narendra in forum Qt Programming
    Replies: 1
    Last Post: 16th December 2009, 14:24
  2. conflict between boost signals and Qt signals
    By high_flyer in forum Qt Programming
    Replies: 2
    Last Post: 26th June 2008, 09:46
  3. QThread and signals (linux/UNIX signals not Qt Signals)
    By Micawber in forum Qt Programming
    Replies: 1
    Last Post: 28th November 2007, 22:18
  4. Problem closing a QMainWindow in Qt4.2
    By ian in forum Qt Programming
    Replies: 11
    Last Post: 17th October 2006, 00:49
  5. run function before closing QMainWindow
    By raphaelf in forum Newbie
    Replies: 1
    Last Post: 31st August 2006, 09:21

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.