I woudn't use the editingFinished signal to validate.

If you want to validate only when the OK button is clicked, do it like this:

Qt Code:
  1. MyDialog::MyDialog(QWidget *parent) :
  2. QDialog(parent),
  3. {
  4. // ...
  5. connect(pushButton_OK, SIGNAL(clicked()), this, SLOT(validate()));
  6. connect(pushButton_Cancel, SIGNAL(clicked()), this, SLOT(reject()));
  7. }
  8.  
  9. void MyDialog::validate()
  10. {
  11. if (lineEdit->text() != "Valid data")
  12. {
  13. QMessageBox::critical(this, tr("Invalid Data"), tr("You entered invalid data"));
  14. return;
  15. }
  16. accept();
  17. }
To copy to clipboard, switch view to plain text mode