1

I have a class which inherits from QDialog (dialog_game_over). I show an object of that class in a slot of another class. I want to close mainwindow and QDialog when user clicked on ok button. First I built an object of mainwindow in dialog_game_over and close it. But this way it wasn't correct. What do I do for closing program in class other than main class?

dilog_game_over::dilog_game_over(QWidget *parent) :
QDialog(parent),x_size(400),y_size(400)
{
    ok=new QPushButton(this);
    ok->setText("OK");
    ok->move(200,200);
    connect(ok,SIGNAL(clicked()),this,SLOT(on_ok_clicked()));
 }
 void dilog_game_over::on_ok_clicked()
 {
   accept();
   this->close();
 }
 class Myenemy1 : public QGraphicsObject
{
  Q_OBJECT
  public slots:
  void loss();
  private:
  dilog_game_over dlg;
}
void Myenemy1::loss()
{
  ....
  dlg.exec();
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),size_of_plane_y(600),size_of_plane_x(2500)
{
  set_scene();
  put_cloud();
  put_point();
}
Nejat
  • 31,784
  • 12
  • 106
  • 138
maryam
  • 1,437
  • 2
  • 18
  • 40

1 Answers1

2

All over your application you can exit by :

qApp->quit();  

Or

qApp->exit(0);
Nejat
  • 31,784
  • 12
  • 106
  • 138
  • thanks for your answer.if possible visit this question.[http://stackoverflow.com/questions/24596801/how-to-restart-an-application-in-qt] – maryam Jul 10 '14 at 10:55