Results 1 to 2 of 2

Thread: Closing Modeless Dialogs from MainWindow Application

  1. #1
    Join Date
    Feb 2013
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Closing Modeless Dialogs from MainWindow Application

    I have a simple MainWindow application that contains one pushbutton. The pushbutton action starts a modeless dialog window (using "show"). When the MainWindow closes, the modeless dialog is still hanging out there. How do you close a modeless dialog from the MainWindow app? Should there be a signal/slot mechanism to perform the modeless dialog close?

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Closing Modeless Dialogs from MainWindow Application

    Are you creating your modeless dialog with the MainWindow as its parent? If so, then the MainWindow destructor should close it automatically. If not (as seems to be the case), then you are telling Qt that this is a top-level window just like MainWindow, so closing MainWindow has no effect (as you observe).

    If you don't want the dialog to be a child of MainWindow, then implement the closeEvent handler for your MainWindow class, and in it close your modeless dialog.

Similar Threads

  1. Replies: 3
    Last Post: 22nd December 2011, 13:55
  2. Dialogs not closing with 'Apple + W' on mac.
    By kaushal_gaurav in forum Qt Programming
    Replies: 5
    Last Post: 16th March 2009, 12:07
  3. Closing all of the mainWindow's child dialogs
    By JPNaude in forum Qt Programming
    Replies: 4
    Last Post: 2nd October 2008, 14:18
  4. MainWindow+Dialogs
    By fruzzo in forum Qt Programming
    Replies: 3
    Last Post: 20th May 2008, 09:52
  5. MainWindow in front of child modeless dialog
    By jiveaxe in forum Qt Programming
    Replies: 4
    Last Post: 10th August 2007, 17:18

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.