Dear Friends,
I am experiencing the following problem when i try to use nested QDialog. i had used .exec() to show those dialogs as modal. when i closed the second one, the first also comes out of the eventloop can any body help me to sort out this error.?

Qt Code:
  1. //**************slot to call dialog1**************************//
  2.  
  3. void SettingWnd::Slot_showDialog()
  4. {
  5. setEnabled(false);
  6. setVisible(false);
  7.  
  8. dialog1 *dialogobj = new dialog1;
  9. dialogobj->exec();
  10.  
  11. setVisible(true);
  12. setEnabled(true);
  13. btnDialup_setting->setFocus();
  14. }
  15.  
  16. //**************Dialog 1**************************//
  17.  
  18.  
  19. dialog1::dialog1(QWidget *parent) :
  20. QDialog(parent),
  21. ui(new Ui::dialog1)
  22. {
  23. ui->setupUi(this);
  24. setParent(MdiArea);
  25. setWindowTitle("Dialog1");
  26. setWindowFlags(Qt::FramelessWindowHint);
  27. setFocusPolicy(Qt::NoFocus);
  28. if(ui->listWidget->count() == 0)
  29. {
  30. ui->listWidget->addItem("No connection added");
  31. }
  32. ui->listWidget->setFocus();
  33. }
  34.  
  35. dialog1::~dialog1()
  36. {
  37. delete ui;
  38. }
  39.  
  40. void dialog1::on_btnAdd_new_clicked()
  41. {
  42. setVisible(false);
  43. setEnabled(false);
  44.  
  45. dialog2 *dialogObj1 = new dialog2;
  46. dialogObj1->exec();
  47.  
  48. delete dialogObj1;
  49. setVisible(true);
  50. setEnabled(true);
  51. ui->btnAdd_new->setFocus();
  52. }
  53.  
  54. //**************Dialog 2**************************//
  55.  
  56. dialog2::dialog2(QWidget *parent) :
  57. QDialog(parent),
  58. ui(new Ui::dialog2)
  59. {
  60. ui->setupUi(this);
  61. setParent(MdiArea);
  62. setWindowTitle("Dialog2");
  63. setWindowFlags(Qt::FramelessWindowHint);
  64. setFocusPolicy(Qt::NoFocus);
  65.  
  66. ui->txtConnectionName->setFocus();
  67. }
  68.  
  69. dialog2::~dialog2()
  70. {
  71. delete ui;
  72. }
To copy to clipboard, switch view to plain text mode 

when i closed the dialog2, dialog1 also comes out of eventloop without closing it....