I have a dialog with LineEdit elements. I want the dialog to close if ENTER is pressed so I added a slot for the returnPressed() signal:
ChPasswd::ChPasswd(QWidget *parent) :
QDialog(parent),
ui(new Ui::ChPasswd)
{
ui->setupUi(this);
connect(ui->NewPasswordInput, SIGNAL(returnPressed()), SLOT(checkPasswords()));
}
At some point I open a message box:
QMessageBox mb(...);
mb.exec();
The box opens and gets the focus. The problem is that when I press ENTER now, the returnPressed signal in ChPasswd fires and checkPasswords() is called. Why is this keyboard event handled?
Alright, I just figured it out. Since this is a dialog pressing ENTER automatically calls another slot. This slot also calls
checkPasswords()and therefor created a second message box which appears as soon as the first one was closed.