title: QT connect crash using signal accepted
body: <p>I have a problem with my Qt code. I wanted to write an program which are taking a coordinates of point and then that point is drawing in point with that coordinates. My program doesn't have any errors or warnings when i built it but it's crashing at start(MainWindow doesn't show). This is my code:</p>
  
  <p>main.cpp</p>
  
  <pre><code>#include &lt; QApplication &gt;
  
  #include "mainwindow.h"
  
  int main(int argc, char *argv[])
  {
      QApplication app(argc, argv);
  
      MainWindow win;
      win.show();
  
      return app.exec();
  }
  </code></pre>
  
  <p>mainwindow.h</p>
  
  <pre><code>#ifndef MAINWINDOW_H
  #define MAINWINDOW_H
  
  #include &lt;QMainWindow&gt;
  #include &lt;QWidget&gt;
  #include &lt;QAction&gt;
  #include &lt;QToolBar&gt;
  #include &lt;QTextCodec&gt;
  #include &lt;QObject&gt;
  #include &lt;QDialog&gt;
  #include &lt;QLineEdit&gt;
  #include &lt;QPushButton&gt;
  #include &lt;QString&gt;
  
  #include "addpoint.h"
  
  class MainWindow: public QMainWindow
  {
      Q_OBJECT
  private:
      QToolBar *AddToolbar;
      QAction *AddPointAction;
  
      AddPoint *AddPointDialog;
  
  
  
      QLineEdit *x;
  
  
  public:
      MainWindow();
  
      void createToolbar();
      void createActionAdd();
  
  signals:
  
  public slots:
      void PointClicked();
      void DialogAccepted();
  };
  
  #endif // MAINWINDOW_H
  </code></pre>
  
  <p>mainwindow.cpp</p>
  
  <pre><code>#include "mainwindow.h"
  
  MainWindow::MainWindow()
  {
      QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
  
      createActionAdd();
      createToolbar();
  
      connect(AddPointAction, SIGNAL(triggered(bool)), this, SLOT(PointClicked()));
  
      connect(AddPointDialog, SIGNAL(accepted()), this, SLOT(DialogAccepted()));
  
      setMinimumSize(480, 320);
  }
  
  /**/
  void MainWindow::createToolbar()
  {
      AddToolbar = new QToolBar;
      AddToolbar-&gt;addAction(AddPointAction);
  
      addToolBar(AddToolbar);
  }
  
  /**/
  void MainWindow::createActionAdd()
  {
      AddPointAction = new QAction("Add Road", this);
  
      x = new QLineEdit(this);
      x-&gt;setFixedSize(100, 30);
      x-&gt;move(100, 100);
  }
  
  /**/
  void MainWindow::PointClicked()
  {
      AddPointDialog = new AddPoint(this);
      AddPointDialog-&gt;setModal(true);
  
      AddPointDialog-&gt;exec();
  }
  
  /**/
  void MainWindow::DialogAccepted()
  {
      x-&gt;setText("abc");
  }
  </code></pre>
  
  <p>addpoint.h</p>
  
  <pre><code>#ifndef ADDPOINT_H
  #define ADDPOINT_H
  
  #include &lt;QWidget&gt;
  #include &lt;QTextCodec&gt;
  #include &lt;QDialog&gt;
  #include &lt;QObject&gt;
  #include &lt;QLabel&gt;
  #include &lt;QLineEdit&gt;
  #include &lt;QPushButton&gt;
  #include &lt;QString&gt;
  
  class AddPoint : public QDialog
  {
      Q_OBJECT
  private:
      QLabel *XpointL;
      QLineEdit *XPoint;
      QPushButton *OKButton;
  
  
  public:
      AddPoint(QWidget *parent);
      void createButton();
  
  signals:
  
  public slots:
  };
  
  #endif // ADDPOINT_H
  </code></pre>
  
  <p>addpoint.cpp</p>
  
  <pre><code>#include "addpoint.h"
  
  AddPoint::AddPoint(QWidget *parent) :QDialog(parent)
  {
      QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
  
      createButton();
  
      connect(OKButton, SIGNAL(clicked(bool)), this, SLOT(accept()));
  
      setMinimumSize(320, 240);
  }
  
  /**/
  void AddPoint::createButton()
  {
      XpointL = new QLabel("Point X:", this);
      XpointL-&gt;setFixedSize(100, 30);
      XpointL-&gt;move(10, 10);
  
      XPoint = new QLineEdit(this);
      XPoint-&gt;setFixedSize(180, 30);
      XPoint-&gt;move(120, 10);
  
      OKButton = new QPushButton("OK", this);
      OKButton-&gt;setFixedSize(100, 30);
      OKButton-&gt;move(200, 150);
  
  }
  </code></pre>
  
  <p>After running the program i see in aplication output lap:
  "The program has unexpectedly finished."
  "C:\QT\build-xxx-Desktop_Qt_5_4_2_MSVC2013_64bit-Debug\debug\xx.exe crashed"</p>
  
  <p>I note that i made some experiments with this code and i saw that i have problem with signal accpeted() at mainwindow.cpp. I don't know what can i do with this problem. I hope you will help me.</p>