Results 1 to 4 of 4

Thread: delete sub windows when they are closed?

  1. #1
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default delete sub windows when they are closed?

    Hi all, I've got a dialog window that can open one or more sub windows. These sub windows are subclasses of QMainWindow. My question is if it's convenient to delete the main windows everytime they are closed or let the application to delete them when the dialog (the parent of the main windows) is closed.

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: delete sub windows when they are closed?

    Just set the Qt::WA_DeleteOnClose attribute.

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

    Dark_Tower (21st March 2006)

  4. #3
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: delete sub windows when they are closed?

    Thanks a lot jacek. I also want to do 2 more questions in adition with the previous:
    1) If I make a connection in the dialog window with a signal from the main window, it's convenient/necesary to disconnect it when the user closes the main window?

    2) I want to know the moment when each window is closed, because the dialog window has to do some updates. Is it a simpler way to know when a sub window is closed than emiting a signal in the closeEvent of the main window?
    Last edited by Dark_Tower; 21st March 2006 at 18:30.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: delete sub windows when they are closed?

    Quote Originally Posted by Dark_Tower
    If I make a connection in the dialog window with a signal from the main window, it's convenient/necesary to disconnect it when the user closes the main window?
    It depends, you probably don't want to disconnect the signal that is connected to QWidget::show(). When QObject is destroying itself, it disconnects all signals.

    Quote Originally Posted by Dark_Tower
    Is it a simpler way to know when a sub window is closed than emiting a signal in the closeEvent of the main window?
    IMO the safest way is adding emit in closeEvent.

  6. The following user says thank you to jacek for this useful post:

    Dark_Tower (22nd March 2006)

Similar Threads

  1. Replies: 4
    Last Post: 19th February 2009, 11:10
  2. Qt Jambi, deploying app on Mac & Windows fails
    By ChrisColon in forum Installation and Deployment
    Replies: 2
    Last Post: 16th February 2009, 22:05
  3. Replies: 5
    Last Post: 15th January 2009, 09:03
  4. c++, placement delete upon exception
    By stinos in forum General Programming
    Replies: 6
    Last Post: 31st October 2006, 15:38
  5. Qt and windows vista
    By munna in forum General Discussion
    Replies: 8
    Last Post: 11th January 2006, 22:33

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.