Results 1 to 4 of 4

Thread: Close event

  1. #1
    Join Date
    Sep 2007
    Posts
    99
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Exclamation Close event

    Hi...got a little question...
    when I create widget this way:
    OpenHistoryView *sentMsgHistoryView = new OpenHistoryView(this);
    and "this" is a MainWindow (main application)...why isnt the widget deleted when I close the MainWindow that is actually a parent of it ?? or it just doesnt behave as I supposed it should ?
    By deleted I mean Destroyed/Closed with the mainwindow....I dont understand why not
    anyone ideas ?
    THANKS

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Close event

    Closing a widget doesn't make Qt delete it by default. You have to either call delete or deleteLater on it explicitely or set the Qt::WA_DeleteOnClose attribute on the widget.

  3. #3
    Join Date
    Sep 2007
    Posts
    99
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Close event

    Im not closing the widget....
    Im closing THE MAINWINDOW that is a parent of that widget and I want that WIDGET to be closed with the mainwindow SINCE the mainwindow is a parent of that widget...
    As I understand that....When I close the parent it should get deleted and all children should get to...

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Close event

    Quote Originally Posted by gyre View Post
    Im not closing the widget....
    Im closing THE MAINWINDOW that is a parent of that widget and I want that WIDGET to be closed with the mainwindow SINCE the mainwindow is a parent of that widget...
    You mean that the window is closed but one of its children remains visible? Somehow I can't even imagine that... Could you post a screenshot?

    As I understand that....When I close the parent it should get deleted and all children should get to...
    No, read my post again - Qt doesn't delete widgets (top level ones, like your main window, included) if you don't ask it to, either by deleting them, deleting their parents or setting the DeleteOnClose attribute on the top level window (or probably any widget).

Similar Threads

  1. QDockWidget-title
    By moowy in forum Qt Programming
    Replies: 18
    Last Post: 23rd April 2014, 20:13
  2. Replies: 1
    Last Post: 16th October 2007, 22:41
  3. The event fired by the mouse click on the frame
    By Placido Currò in forum Qt Programming
    Replies: 8
    Last Post: 3rd March 2007, 09:05
  4. event problem
    By windkracht8 in forum Qt Programming
    Replies: 5
    Last Post: 17th August 2006, 11:52
  5. Workload in a QThread blocks main application's event loop ?
    By 0xBulbizarre in forum Qt Programming
    Replies: 14
    Last Post: 9th April 2006, 21:55

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.