title: Qt Run Single Application
body: <p>I have a few dialogs and buttons that call these dialogs. However, every click on the button calls a new dialog window. I want the existing window to close first before the user can click on the button to open another.</p>
  
  <p>Below is an example of a button calling a slot. Whenever I click on the button, it will call a copy of the dialog window. Is there any way to only call one copy of the dialog window only?</p>
  
  <p>Thanks.</p>
  
  <p>Bookmark.cpp:</p>
  
  <pre><code>Bookmark::Bookmark()
  {
      createButtons();
      connect(bookmarkButton, SIGNAL(clicked()), this, SLOT(openBookmarkDlg()));
  }
  
  void Bookmark::createButtons()
  {
      ...
  
      bookmarkButton = new QToolButton;
      bookmarkButton-&gt;setText("Bookmark");
      addWidget(bookmarkButton);
  
      ...
  }
  
  void Bookmark::openBookmarkDlg()
  {
      BookmarkDlg *bkDlg = new BookmarkDlg;
      bkDlg-&gt;show();
  }
  </code></pre>
  
  <p>Bookmark.h:</p>
  
  <pre><code>class Bookmark : public QToolBar
  {
      Q_OBJECT
  
  public:
      Bookmark(void);
      ~Bookmark(void);
  
  public slots:
      void openBookmarkDlg();
  
  private:
      createButtons();
      QToolButton *bookmarkButton;
  };
  </code></pre>