title: My qt desktop app keeps crashing after I close out of my starting child dialog and go into my parent dialog
body: <p>So I am quite new to qt, and am trying to open a desktop app with a child dialog, and when I click a button it points to the parent dialog. I managed to do that, but whenever I run it and click 'go' it points me to my parent window and then crashes! I got the code from <a href="https://stackoverflow.com/questions/25781149/qt-how-to-open-a-new-main-window-on-push-button-click-and-delete-original-main">this link</a>. the first answer was what got it to work, and the second one didn't work at all. my MainWindow (parent) dialog is survey and my child dialog is global. (I know I named them weird. Still learning).</p>
  <p>my main.cpp</p>
  <pre><code>#include &quot;survey.h&quot;
  #include &lt;QApplication&gt;
  #include &quot;global.h&quot;
  
  
  int main(int argc, char *argv[])
  {
      QApplication a(argc, argv);
  
  
      QWidget survey;
      survey.show();
      global popup(&amp;survey);
      popup.show();
  
  
  
  /*
      survey w;
      w.show();
  */
      return a.exec();
  }
  </code></pre>
  <p>my global.cpp</p>
  <pre><code>#include &quot;global.h&quot;
  #include &quot;ui_global.h&quot;
  #include &quot;survey.h&quot;
  
  global::global(QWidget *parent) :
      QDialog(parent),
      ui(new Ui::global)
  {
      ui-&gt;setupUi(this);
  }
  
  global::~global()
  {
      delete ui;
  }
  
  
  
  void global::on_Go_clicked()
  {
  
      //survey *nWin;
  
  
      auto win = new survey();
      win-&gt;setAttribute(Qt::WA_DeleteOnClose);
      win-&gt;show();
      deleteLater();
  
  }
  </code></pre>
  
  <p>What do I need to change so my desktop app doesn't crash when I run it??</p>