title: Restrict QDialog window to one instance [Qt]?
body: <p>I have a Qt GUI application that opens a dialog when I go to Help > About. However, if I go to Help > About again, another dialog pops up. I'm trying to get it so that the already opened About dialog is the only one that can be open (i.e. no additional About dialogs allowed). I feel like this should be simple, but I keep getting a Segmentation Fault. Here's my code:</p>
  
  <p><strong>myApp.h</strong></p>
  
  <pre><code>#ifndef MYAPP_H
  #define MYAPP_H
  
  #include &lt;QMainWindow&gt;
  #include "about.h"
  
  namespace Ui {
  class MyApp;
  }
  
  class MyApp : public QMainWindow // inherit all public parts of QMainWindow
  {
    Q_OBJECT
  
  public:
    explicit MyApp(QWidget* parent = 0);
    ~MyApp();
  
  private slots:
    void on_actionAbout_triggered();
  
  private:
    Ui::MyApp* ui;
    About* aboutDialog;
  };
  
  #endif // MYAPP_H
  </code></pre>
  
  <p><strong>MyApp.cpp</strong></p>
  
  <pre><code>#include "MyApp.h"
  #include "ui_MyApp.h"
  #include "about.h"
  
  MyApp::MyApp(QWidget* parent) :
    QMainWindow(parent),
    ui(new Ui::MyApp)
  {
    ui-&gt;setupUi(this);
  }
  
  MyApp::~MyApp()
  {
    delete ui;
  }
  
  void MyApp::on_actionAbout_triggered()
  {
    if (!aboutDialog) {
      aboutDialog = new About(this);  // create new window
    }
    aboutDialog-&gt;show();
    aboutDialog-&gt;activateWindow();
  }
  </code></pre>
  
  <p><strong>about.h</strong></p>
  
  <pre><code>#ifndef ABOUT_H
  #define ABOUT_H
  
  #include &lt;QDialog&gt;
  
  namespace Ui {
  class About;
  }
  
  class About : public QDialog
  {
    Q_OBJECT
  
  public:
    explicit About(QWidget* parent = 0);
    ~About();
  
  private:
    Ui::About* ui;
  };
  
  #endif // ABOUT_H
  </code></pre>
  
  <p><strong>about.cpp</strong></p>
  
  <pre><code>#include "about.h"
  #include "ui_about.h"
  
  About::About(QWidget* parent) :
    QDialog(parent),
    ui(new Ui::About)
  {
    ui-&gt;setupUi(this);
  }
  
  About::~About()
  {
    delete ui;
  }
  </code></pre>
  
  <p>In <code>MyApp.cpp</code>, when I get rid of the <code>if</code>, it works. But clicking Help > About (actionAbout_triggered) multiple times will open a bunch of About windows. I just want 1. So I figured I'd put in an if statement that says, if the About dialog is already open, don't create another one and just make it the active window instead. I'm met with a Segmentation Fault. I know this means it's trying to access memory somewhere that it shouldn't be, but I don't know why.</p>
  
  <p>Any help would be greatly appreciated.</p>