title: How to close the main window when a dialog appears
body: <p>I was making a test program where the MainWindow serves as a login screen. User types in a username and password. If they match what the string is assigned to, then the Dialog appears. If it fails, a QMessageBox appears instead.</p>
  <p>What my issue is when I want the Dialog to appear (the main program), I want the Login page to disappear. The Command close(); would just close everything.</p>
  <p>Here is the code for the MainWindow.cpp (The Dialog is referenced in the header as a POINTER called mDialog)</p>
  <pre><code> void MainWindow::on_pushButton_clicked()
   {
   if (ui-&gt;lineEdit-&gt;text() == username)
   {
      if (ui-&gt;lineEdit_2-&gt;text() == password)
      {
          //This is where the Dialog appears
          mDialog= new MyDialog(this);
          mDialog-&gt;show();
      }
  }
  else if (ui-&gt;lineEdit-&gt;text() != username || ui-&gt;lineEdit-&gt;text() ==NULL)
  {
      if (ui-&gt;lineEdit_2-&gt;text() != password || ui-&gt;lineEdit_2-&gt;text() == NULL)
      {
          QMessageBox::warning(this, &quot;Error&quot;, &quot;The username or password is incorrect.&quot;);
      }
   }
  }
  </code></pre>
  <p>Here is the code for the main.cpp</p>
  <pre><code>int main(int argc, char *argv[])
  {
  QApplication a(argc, argv);
  MainWindow w;
  w.show();
  
  return a.exec();
  }
  </code></pre>