0

Is it correct to call saveState method in destructor of QMainWindow? Or should I do it in QMainWindow::closeEvent (as in documentation)?

I have problems in some project with saving state from destructor. It seems to me, that in destructor of QMainWindow state maybe already incorrect, and then restoring from broken state gives strange results. Moving of saving state from destructor to closeEvent method fixes problem.

poljak181
  • 585
  • 4
  • 12
  • Decision whether to call it from the destructor or from the close event handler depends on how your main window destroyed. – vahancho Feb 27 '19 at 12:20
  • @vahancho How should it depends? In my case normal way - closing window with left mouse click on close button. – poljak181 Feb 27 '19 at 12:59
  • If closing the main window the only way to exit the application than close event handler is the right place. – vahancho Feb 27 '19 at 13:18

0 Answers0