I've the following problem, i want to block the user to close dialog using the 'X' icon or escape key, i know that using something like this will work

Qt Code:
  1. void MyMainDialog::done( int res )
  2. {
  3.  
  4. if( allowClose )
  5. QDialog::done(res);
  6. }
  7.  
  8.  
  9.  
  10. void MyMainDialog::closeEvent( QCloseEvent* e )
  11. {
  12.  
  13. if( allowClose )
  14. e->accept();
  15. else
  16. e->ignore();
  17. }
To copy to clipboard, switch view to plain text mode 

Above code works fine and blocks the main dialog,
but now i created this dialog called from maindialog and i want also to block it

Qt Code:
  1. void MyMainDialog::text_dialog()
  2. {
  3.  
  4. text_dlg = new QDialog( this );
  5. dlg_layout = new QVBoxLayout( text_dlg );
  6. ..........
  7. ..........
  8. text_dlg->exec();
  9. }
To copy to clipboard, switch view to plain text mode 

Something like connect( on_close_text_dlg, SIGNAL(clicked()), this, SLOT( block_it() ));
will be the proper way to do this? i tried, but couldn't find what will be the way to receive the event type for a on_close_text_dlg
How i block the text_dlg?