I am having an issue trying to validate some input in QT4.
I have a form with 2 textEdit fields. When one field loses focus, I want it to check if the field is empty, and if so, alert the user.
Here is my code:
void newconsole::on_nameEdit_lostFocus()
{
if (this->ui->nameEdit->text().size() < 1)
{
QMessageBox b;
b.setText("Name must be longer than 0 characters.");
b.setIcon(QMessageBox::Information);
b.setStandardButtons(QMessageBox::Ok);
b.show();
}
}
void newconsole::on_fileextensionEdit_lostFocus()
{
if (this->ui->fileextensionEdit->text().size() < 1)
{
QMessageBox b;
b.setText("File extension must be longer than 0 characters.");
b.setIcon(QMessageBox::Information);
b.setStandardButtons(QMessageBox::Ok);
b.show();
}
}
My issue is that when I run the form and lose focus on the first textEdit (nameEdit) I get a MessageBox from BOTH signals. Any suggestions?
my guess would be:
hope this helps, regards