Hi

I need to close the dialog box using a button. I have 4 line edits and i need to save the values into a variable before closing the dialog.

I have a mainwindow and a dialog.

this is my code, to open the dialog b4 the main window.

Qt Code:
  1. void desktop::newdevice()
  2. {
  3. QDialog dlg;
  4. Ui::newdevice newui;
  5. newui.setupUi(&dlg);
  6.  
  7. identityreaddata();
  8. dlg.setWindowTitle("Title");
  9. newui.statuslabel->setText("Please enter the details");
  10.  
  11. //if(dev_email == '\0' || dev_serialno == '\0'|| dev_devicename == '\0' )
  12. {
  13. if(dlg.exec()== QDialog::Accepted);
  14. {
  15. devicename = newui.devnameEdit->text();
  16. password = newui.passEdit->text();
  17. email = newui.emailEdit->text();
  18. slno = newui.slnoEdit->text();
  19. qDebug () << "device name"<<devicename;
  20. qDebug () << "password"<<password;
  21. qDebug () << "email"<<email;
  22. qDebug () << "slno"<<slno;
  23. connect(newui.updateButton, SIGNAL(clicked()),SLOT (QDialog::close()));
  24.  
  25. }
To copy to clipboard, switch view to plain text mode 

but when i press the update button, the dialog doesnt close. I have to press the x button on the right top corner to close it.

Can somebody help me with this??