[Solved] Accepted signal from QDialogButtonBox
-
Hi all
I am making a login screen where the user has to enter his username and password. I use a QDialogButtonBox with ok and cancel buttons. My problem is if the user enters incorrect credentials and clicks on the ok button the button is somehow always connected to the accepted signal and closes the dialog.
What can I do so the dialog wont quit when the user enters incorrect credentials, but instead just clears out the input from the user and lets him try again.
In .net I would simply do this: DialogResult = DialogResult.None to cancel out the closing of the dialog.
How can I do this in Qt ?
Thanks
DarkRoast -
Reimplement "QDialog::accept()":http://doc.trolltech.com/4.7/qdialog.html#accept
-
Thanks mlong
this is how I ended up doing it:
@void LoginScreen::accept()
{
if(LoginToDB())
{
done(QDialog::Accepted);
}
}bool LoginScreen::LoginToDB()
{
bool ret = w->LogintoMusicDB(ui->userLineEdit->text(), ui->passwordLineEdit->text());if(!ret) { ui->labelError->setText("Could not log into database!"); ui->userLineEdit->setText(""); ui->passwordLineEdit->setText(""); return false; } return true;
}@