Hello all. In my application i have my saveSettings virtual method, that saves widget settings. This widgets using as MDI children, QDialog children and as standalone windows. What signal handler shoould I prefer to use to call my saveSettings? Destructors is not solution, because my method is virtual and call my virtual method from destructor will results undefined behaviour. loadSettings must be called AFTER child widgets are created, and loadSettings must be called BEFORE child widgets are destroyed. Here is my C++11 code:

Qt Code:
  1. template<class T> class ICSWidget_Template: public T {
  2. protected:
  3. virtual void loadSettings() = 0;
  4. virtual void saveSettings() = 0;
  5.  
  6. virtual void showEvent(QShowEvent* pEvent) override {
  7. T::showEvent(pEvent);
  8.  
  9. if(!m_bInitialized) {
  10. loadSettings();
  11. m_bInitialized = true;
  12. }
  13. }
  14.  
  15. // Some stuff to call saveSettings?
  16.  
  17. private:
  18. bool m_bInitialized = false;
  19. };
  20.  
  21.  
  22. /*
  23.   This is usage of ICSWidget_Template
  24. */
  25. class ICSMainWindow: public ICSWidget_Template<QMainWindow> {
  26. // App-specific code
  27. };
To copy to clipboard, switch view to plain text mode