Qt Code:
  1. void MainWindow::getFormdetails()
  2. {
  3. fd = new formDialog();
  4.  
  5. if(fd->exec() == 1)
  6. {
  7. data = fd->returnFormdata();
  8. qDebug() << data;
  9. }
  10. }
  11.  
  12. formDialog::formDIalog()
  13. {
  14. connect(okButton, SIGNAL(clicked()), this, SLOT(formFieldCheck()));
  15. //connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
  16. connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
  17. }
  18. void formDialog::formFieldCheck()
  19. {
  20. if(formLedit[0]->text().isEmpty() || formLedit[1]->text().isEmpty())
  21. { QMessageBox::information(this, tr("Empty Field"),
  22. tr("Please enter a name."));
  23.  
  24. }
  25. else {list.append(formLedit[0]->text());
  26. list.append(formLedit[1]->text());
  27. list.append(age->text());
  28. list.append(gender->currentText());
  29. accept(); // Call accept here
  30. //this->hide();
  31. }
  32. }
  33.  
  34. QStringList formDialog::returnFormdata()
  35. {
  36. return list;
  37. }
To copy to clipboard, switch view to plain text mode