Page 1 of 2 12 LastLast
Results 1 to 20 of 23

Thread: Calling destructors on close event

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

    Question Calling destructors on close event

    Hi...I have a question about calling constructors on close events...
    I have implemented a close event for my MainWindow plus I set an attribute of mainwindow that sets it to delete itself when closed:

    setAttribute(Qt::WA_DeleteOnClose);

    But....when I create some widgets with this mainwindow as their parent they wont delete themselves when they are displayed at the time when the mainwindow is closed. Yes they get closed with the mainwindow but I think theyre not deleted.... I dont understand that since it should deleteOnClose as set in that attribute I mentioned and with its delete it should delete all of its child widgets...
    Am I right or wrong ?
    Problem is that my app doesnt exit when I close it at the time when some of its child widgets were not closed yet and are displayed with it. When I close the app MainWindow the process is still running in the background and it does not finish running...Mainwindow gets closed but stays running in a background process....so I assumed that it has to do something with not deleting of child widgets that are displayed when closing its parents....
    Does anyone know how to fix this ?
    Thanks in advance...
    Last edited by gyre; 27th November 2007 at 06:04. Reason: updated contents

  2. #2
    Join Date
    Oct 2007
    Location
    Munich, Bavaria
    Posts
    144
    Thanks
    1
    Thanked 19 Times in 19 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Calling destructors on close event

    Can you please post some code. It'll be easier for us to analyse.

    Good luck,

    Tom

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

    Default Re: Calling destructors on close event

    The application gets closed when the last window gets closed (regardless of whether it is destroyed or not). So until at least one top-level window remains visible, your application won't autoclose itself. And if some widgets remain visible when you close the main window, it means they are not children of the main window (you didn't pass a pointer to the main window as the parent agument to their constructor).

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

    Default Re: Calling destructors on close event

    I said THEY DONT REMAIN VISIBLE....they get closed with the main window BUT the process of application is still running even after I close it...
    But this happens ONLY when I close main window when some of its child widgets are displayed...If they are not displayed when closing the mainwindow the prcess of app gets finished with the close correctly...
    Qt Code:
    1. void MainWindow::on_actionViewSentMsgHistory_triggered()
    2. {
    3. qDebug("DISPLAY MESSAGE HISTORY TABLE VIEW");
    4. OpenHistoryView *sentMsgHistoryView = new OpenHistoryView(this);
    5. sentMsgHistoryView->historyTableView->setModel(sentMsgHistory);
    6. sentMsgHistoryView->show();
    7. }
    8.  
    9. void MainWindow::on_sendMultiMessage_triggered()
    10. {
    11. qDebug("DISPLAY MULTIMESSAGE DIALOG AND SEND");
    12. MsgSeqWidget *widget = new MsgSeqWidget(this);
    13. widget->show();
    14. }
    To copy to clipboard, switch view to plain text mode 

    those are ONLY TWO child widgets...

    headers of those widgets:
    Qt Code:
    1. class OpenHistoryView : public QMainWindow, public Ui::historyView
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. OpenHistoryView(QMainWindow *parent = NULL);
    7. ~OpenHistoryView();
    8. void contextMenuEvent(QContextMenuEvent *event);
    9.  
    10. QAction *sendAction;
    11.  
    12. public slots:
    13. void on_cancelButton_clicked();
    14. void on_sendButton_clicked();
    15. void on_removeSelectedButton_clicked();
    16. void on_removeAllButton_clicked();
    17.  
    18. void sendMessages();
    19. };
    20.  
    21. class MsgSeqWidget : public QMainWindow , public Ui::MsgSeqEditor
    22. {
    23. Q_OBJECT
    24. public:
    25. MsgSeqWidget(QMainWindow *parent= NULL);
    26. ~MsgSeqWidget();
    27. QVcaMsgSeqModel *model;
    28. void dragEnterEvent(QDragEnterEvent *event);
    29. void dropEvent(QDropEvent *event);
    30. signals:
    31. void msgEnqueue(const QVcaCanMsg &canmsg);
    32. public slots:
    33. void on_addMsgButton_clicked();
    34. void on_cancelButton_clicked();
    35. void on_removeMsgButton_clicked();
    36. void on_sendMsgButton_clicked();
    37. };
    To copy to clipboard, switch view to plain text mode 

    and constructors:

    Qt Code:
    1. OpenHistoryView::OpenHistoryView(QMainWindow *parent)
    2. : QMainWindow(parent)
    3. {
    4. setupUi(this);
    5. setWindowTitle("Sent Message History View");
    6. historyTableView->setSortingEnabled(true);
    7. sendAction = new QAction(tr("&Send"), this);
    8. connect(sendAction, SIGNAL(triggered()),
    9. this, SLOT(sendMessages()));
    10. setAttribute(Qt::WA_DeleteOnClose);
    11. }
    12.  
    13. MsgSeqWidget::MsgSeqWidget(QMainWindow *parent)
    14. : QMainWindow(parent)
    15. {
    16. setupUi(this);
    17. setWindowTitle("Send Message Sequence Tool");
    18. model = new QVcaMsgSeqModel(this);
    19. msgTableView->setModel(model);
    20. msgTableView->setSortingEnabled(true);
    21. msgTableView->setColumnWidth(2, 180);
    22. setAttribute(Qt::WA_DeleteOnClose);
    23. connect(this, SIGNAL(msgEnqueue(const QVcaCanMsg&)),
    24. model, SLOT(messageEnqueued(const QVcaCanMsg&)));
    25. }
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Calling destructors on close event

    and what about main() and MainWindow? As I said, the fact that a widget gets deleted or not is meaningless. The application reacts to widgets being closed, not destroyed. You might be blocking the event loop somehow.

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

    Default Re: Calling destructors on close event

    main:

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. Q_INIT_RESOURCE(mystyle);
    4.  
    5. QApplication app(argc, argv);
    6. MainWindow *mainWindow;
    7.  
    8. QCoreApplication::setOrganizationName("CTU");
    9. QCoreApplication::setOrganizationDomain("www.cvut.cz");
    10. QCoreApplication::setApplicationName("qcanalyzer");
    11.  
    12. vca_debug_flg |= VCA_DEB_MSGDATA | VCA_DEB_RAWMSG;
    13.  
    14. if (argc != 2)
    15. {
    16. mainWindow = new MainWindow;//load default settings when no settings file specified
    17. } else {
    18. mainWindow = new MainWindow(QCoreApplication::arguments().at(1));//load settings from specified filename
    19. }
    20.  
    21. mainWindow->show();
    22. return app.exec();
    23. }
    To copy to clipboard, switch view to plain text mode 

    MainWindow header:
    Qt Code:
    1. class MainWindow : public QMainWindow, private Ui::mainWindow
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. MainWindow(QMainWindow *parent = NULL);
    7. MainWindow(QString settingsFileNamePath, QMainWindow *parent = NULL);
    8. ~MainWindow();
    9.  
    10. QVcaCanMsgModel* getModel(){
    11. return msgTableModel;
    12. }
    13.  
    14. QVcaCanMsgModel* getMsgHistoryModel(){
    15. return sentMsgHistory;
    16. }
    17.  
    18. AppSettings* getSettings(){
    19. return appSettings;
    20. }
    21.  
    22. QVcaNet* getNetworkIfc(){
    23. return networkIfc;
    24. }
    25.  
    26. void setClientConnected(bool _clientConnected){
    27. clientConnected = _clientConnected;
    28. }
    29.  
    30. bool clientIsConnected(){
    31. return clientConnected;
    32. }
    33.  
    34. bool saveFile(const QString &fileName);
    35.  
    36. protected:
    37. void closeEvent(QCloseEvent *event);
    38. void contextMenuEvent(QContextMenuEvent *event);
    39. bool maybeSaved();
    40. private:
    41. bool clientConnected;//WHEN MONITORTHREAD BECOMES A MEMBER OF MAINWINDOW THIS WILL NO MORE MAKE SENSE - WILL BE ASKING EITHER IF THREAD IS RUNNING OR IF IT WAS CREATED-IT CAN BE DELETED WITH PAUSE...
    42.  
    43. AppSettings *appSettings;
    44. QVcaCanMsgModel *msgTableModel;
    45. QVcaNet *networkIfc;
    46. AnalyzerMonitorThread *monitorThread;
    47.  
    48. QVcaCanMsgModel *sentMsgHistory;
    49.  
    50. signals:
    51. void msgHistoryUpdate(const QVcaCanMsg &canmsg);
    52.  
    53. public slots:
    54. void on_actionAbout_triggered();
    55. void on_actionConfigure_triggered();
    56. void on_actionAttachToInterface_triggered();
    57. void on_actionDetachInterface_triggered();
    58. void on_roughMsgCheckBox_stateChanged();
    59. void on_viewStatsCheckBox_stateChanged();
    60. void on_sendButton_clicked();
    61. void on_periodicButton_clicked();
    62. void on_clearButton_clicked();
    63. void on_followLogHeadCheckBox_stateChanged();
    64. void unsetFollowHeadCheckBox(int state);
    65.  
    66. void on_actionOpenLogFile_triggered();
    67. void changeIndexToMsgLog();
    68.  
    69. bool on_actionSaveLogFile_triggered();
    70.  
    71. void on_actionViewSentMsgHistory_triggered();
    72.  
    73. void on_sendMultiMessage_triggered();
    74. void on_actionFilterView_triggered();
    75.  
    76. void monitorThreadFinished();
    77. };
    To copy to clipboard, switch view to plain text mode 

    Mainwindow constructors:

    Qt Code:
    1. MainWindow::MainWindow(QMainWindow *parent)
    2. : QMainWindow(parent), clientConnected(false), appSettings(new AppSettings(this)) , msgTableModel(new QVcaCanMsgModel(this)), networkIfc(new QVcaNet(this)), monitorThread(NULL), sentMsgHistory(new QVcaCanMsgModel(this))
    3. {
    4. setupUi(this);
    5. msgLog->setModel(msgTableModel);
    6. //msgLog->verticalHeader()->resizeSections(QHeaderView::ResizeToContents);
    7. msgLog->setSortingEnabled(true);
    8. msgLog->setColumnWidth(2, 130);
    9. msgLog->setColumnWidth(4, 180);
    10. msgLog->setDragEnabled(true);
    11. connect(msgLog->verticalScrollBar(), SIGNAL(sliderMoved(int)),
    12. this, SLOT(unsetFollowHeadCheckBox(int)));
    13.  
    14. connect(this, SIGNAL(msgHistoryUpdate(const QVcaCanMsg&)),
    15. sentMsgHistory, SLOT(messageEnqueued(const QVcaCanMsg&)));
    16. setAttribute(Qt::WA_DeleteOnClose);
    17. }
    18.  
    19. MainWindow::MainWindow(QString settingsFileNamePath, QMainWindow *parent)
    20. : QMainWindow(parent), clientConnected(false), appSettings(new AppSettings(settingsFileNamePath, this)) , msgTableModel(new QVcaCanMsgModel(this)), networkIfc(new QVcaNet(this)), monitorThread(NULL), sentMsgHistory(new QVcaCanMsgModel(this))
    21. {
    22. setupUi(this);
    23. msgLog->setModel(msgTableModel);
    24. //msgLog->verticalHeader()->resizeSections(QHeaderView::ResizeToContents);
    25. msgLog->setSortingEnabled(true);
    26. msgLog->setColumnWidth(2, 130);
    27. msgLog->setColumnWidth(4, 180);
    28. msgLog->setDragEnabled(true);
    29. connect(msgLog->verticalScrollBar(), SIGNAL(sliderMoved(int)),
    30. this, SLOT(unsetFollowHeadCheckBox(int)));
    31.  
    32. connect(this, SIGNAL(msgHistoryUpdate(const QVcaCanMsg&)),
    33. sentMsgHistory, SLOT(messageEnqueued(const QVcaCanMsg&)));
    34. setAttribute(Qt::WA_DeleteOnClose);
    35. }
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Calling destructors on close event

    But I dont get it...if none of those two widgets are not displayed when Im closing thw window everything works just fine...
    Understand...those two widgets are actually QMainWindows too...MainWindow is just their parent....they dont part of mainwindow...they are displayed upon som Qaction

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

    Default Re: Calling destructors on close event

    Show me the contents of the close event.

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

    Default Re: Calling destructors on close event

    Close event:
    Qt Code:
    1. void MainWindow::closeEvent(QCloseEvent *event)
    2. {
    3. if(maybeSaved()){
    4. event->accept();
    5. } else {
    6. event->ignore();
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

    Method maybeSaved():

    Qt Code:
    1. bool MainWindow::maybeSaved()
    2. {
    3. QString fileName;
    4. if(msgTableModel->rowCount()) {
    5. QMessageBox::StandardButton ret;
    6. ret = QMessageBox::warning(this, tr("QCanalyzer"),
    7. tr("The Log is not empty.\n"
    8. "Do you want to save actual Log?"),
    9. QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
    10. if (ret == QMessageBox::Save){
    11. if(clientIsConnected()){
    12. on_actionDetachInterface_triggered();
    13. }
    14. fileName = QFileDialog::getSaveFileName(this, tr("Save MsgLog File"), "/home/gyre/temp", tr("Text LogFiles(*.tlog);;Bin LogFiles(*.blog);;Any File(*)"));
    15. if (fileName.isEmpty()){
    16. return false;
    17. } else {
    18. return saveFile(fileName);
    19. }
    20. }
    21.  
    22. if(ret == QMessageBox::Discard){
    23. if(clientIsConnected()){
    24. on_actionDetachInterface_triggered();
    25. }
    26. return true;
    27. }
    28.  
    29. if(ret == QMessageBox::Cancel){
    30. return false;
    31. }
    32. } else if(clientIsConnected()){
    33. on_actionDetachInterface_triggered();
    34. return true;
    35. }
    36.  
    37. return true;
    38. }
    To copy to clipboard, switch view to plain text mode 

    Thanks man for dealing with this...

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

    Default Re: Calling destructors on close event

    Ok, time for some tests. Comment out the close event and add destructors to both child window classes. Inside them just qDebug() something so that you can see if they are called. Do the same for your main window, run the application and see if all the messages are displayed when you close the app.

    Oh, and don't start any additional threads. Comment out whatever is needed.

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

    Default Re: Calling destructors on close event

    I put qDebug() in their destructors...they are called...the debug prints are printed correctly...but the process does not get finished and is still running
    Ah...I havent commented out the close event...shit
    Wait
    Last edited by gyre; 27th November 2007 at 15:40. Reason: updated contents

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

    Default Re: Calling destructors on close event

    Yes the behaviour stays the same...
    They get closed, htey call their destructors but the proces does not get finished...
    Even after I commented out the close event

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

    Default Re: Calling destructors on close event

    Something is occupying the event loop then. Add the following code to your main():

    Qt Code:
    1. class Mark : public QObject {
    2. public:
    3. Mark() : QObject(){ startTimer(1000); }
    4. ~Mark() { qDebug() << "Mark destroyed"; }
    5. protected:
    6. void timerEvent(QTimerEvent*){
    7. qDebug() << QDateTime::currentDateTime();
    8. }
    9. };
    10.  
    11. int main(...){
    12. //...
    13. mainWindow->show();
    14. Mark m;
    15. return app.exec();
    16. }
    To copy to clipboard, switch view to plain text mode 

    You should be receiving marks every second during all time the application runs. See if you still receive them after closing those windows.

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

    Default Re: Calling destructors on close event

    Yes I still receive them after closing the MainWindow that closes child widgets...

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

    Default Re: Calling destructors on close event

    Isnt the problem of this....setting that attribute of main window:
    setAttribute(Qt::WA_DeleteOnClose); ??
    That it gets delted before tha app event loop gets finished ?
    When I deleted that attribute from codes...when I open on of those two child windows...then I close mainwindow it gets closed but those two widgets stay displayed and they dont get closed with the mainwindow...but when I close both of them then event loop finishes correctly...
    Last edited by gyre; 27th November 2007 at 16:15. Reason: updated contents

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

    Default Re: Calling destructors on close event

    Quote Originally Posted by gyre View Post
    Isnt the problem of this....setting that attribute of main window:
    setAttribute(Qt::WA_DeleteOnClose); ??
    That it gets delted before tha app event loop gets finished ?
    When I deleted that attribute from codes...when I open on of those two child windows...then I close mainwindow it gets closed but those two widgets stay displayed and they dont get closed with the mainwindow...but when I close both of them then event loop finishes correctly...
    The attribute is not necessary here and you can safely remove it. I'm having a hard time understanding - if you close the "main" mainwindow, do the other two get closed as well or not?

    BTW. If you still receive marks, then either the lastWindowClosed() signal doesn't fire or some window remains open.

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

    Default Re: Calling destructors on close event

    Quote Originally Posted by wysota View Post
    The attribute is not necessary here and you can safely remove it. I'm having a hard time understanding - if you close the "main" mainwindow, do the other two get closed as well or not?
    Im going to explain it again...
    I have Application MainWindow created. I have prepared two widgets that are in application created and displayed upon clicking on some button by calling their constructor with mainwindow as their parent..So the app mainwindow is their parent.
    Now.. I execute app...mainwindow gets created. I click on a button that creates those two child widgets. Then I close the mainwindow (see Im closing the mainwindow before closing those two child widgets that were displayed upon clicking on some mainwindow button). SO I close the mainwindow and now 2 situations happen:

    1) If I dont have set this attribute: in mainwindow setAttribute(Qt::WA_DeleteOnClose);
    then those two child widgets dont get closed with the main window and they stay displayed even after its parent widget was closed

    2) If I set this attribute in mainwindow then those two widgets get destroyed with the mainwindow but the application eventloop is still running apparenetly because the proces in which application is running doesnt get finished....

    I hope I was clear now

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

    Default Re: Calling destructors on close event

    Ok, I made a check - if a widget has the DeleteOnClose attribute set, it won't make the application emit lastWindowClosed() signal and thus the application won't quit.

    Here is the sample code:
    Qt Code:
    1. #include <QMainWindow>
    2. #include <QApplication>
    3. #include <QPushButton>
    4. #include <QLayout>
    5.  
    6. class MW : public QMainWindow {
    7. Q_OBJECT
    8. public:
    9. MW() : QMainWindow(){
    10. QWidget *w = new QWidget;
    11. QVBoxLayout *l = new QVBoxLayout(w);
    12. b1 = new QPushButton("W1");
    13. l->addWidget(b1);
    14. b2 = new QPushButton("W2");
    15. l->addWidget(b2);
    16. connect(b1, SIGNAL(clicked()), SLOT(doIt()));
    17. connect(b2, SIGNAL(clicked()), SLOT(doIt()));
    18. //setAttribute(Qt::WA_DeleteOnClose);
    19. setCentralWidget(w);
    20. }
    21. private:
    22. QPushButton *b1, *b2;
    23. private slots:
    24. void doIt(){
    25. QMainWindow *mw = new QMainWindow(this, Qt::Window);
    26. mw->setAttribute(Qt::WA_DeleteOnClose);
    27. mw->show();
    28. }
    29. };
    30.  
    31. #include "main.moc"
    32.  
    33. int main(int argc, char **argv){
    34. QApplication app(argc, argv);
    35. MW mw;
    36. mw.show();
    37. // MW *mw = new MW;
    38. // mw->show();
    39. return app.exec();
    40. }
    To copy to clipboard, switch view to plain text mode 

    If you run the code, it works as expected in that way that it quits the app when the last of the windows gets closed, but it doesn't close those child windows. If you uncomment the commented entries and comment out their counterparts, closing the main window will close and delete the children, but will not quit the application.

    A solution is not to use DeleteOnClose attribute on the main window and to delete the child windows in the close event if you need such behaviour. Then it will all work as expected. An alternative is to call QCoreApplication::quit() in the close event of the main window or to connect the destroyed() signal of the main window to the quit() slot of the application. Then you'll be able to use DeleteOnClose.

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

    Default Re: Calling destructors on close event

    A solution is not to use DeleteOnClose attribute on the main window and to delete the child windows in the close event if you need such behaviour.

    Yes but HOW ? How do I delete child windows in close event ? is there a method that enable me to do that ?

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

    Default Re: Calling destructors on close event

    Quote Originally Posted by gyre View Post
    Yes but HOW ? How do I delete child windows in close event ? is there a method that enable me to do that ?
    Hmmm... I might not be understanding the question, because the answer seems obvious - call delete or deleteLater() on each of the child windows.

    But I'd suggest connecting the destroyed() signal of the main window to the app's quit() slot.

Similar Threads

  1. Close event
    By gyre in forum Newbie
    Replies: 3
    Last Post: 20th November 2007, 13:49

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.