困っています。ログインフォームとして QDialog があります。ログインすると、フォームが閉じてメインウィンドウが表示されます。私のログインは問題ありませんが、閉じると QDialog::Rejected が返されます。
QDialog::Rejected が返されないようにするにはどうすればよいですか? また、いつ QDialog::Rejected を返すのでしょうか?
ログイン時のコード:
void Login::on_cmdLogin_clicked()
{
if( ui->txtUsernameLogin->text().isEmpty() || ui->txtPassLogin->text().isEmpty() )
{
QMessageBox::critical(this, "Vocabulary Trainer", "Please fill in both textboxes.", QMessageBox::Ok);
return;
}
User user(filepath + "/users.txt");
if ( user.checkPassword( ui->txtUsernameLogin->text(), ui->txtPassLogin->text() ))
{
username = ui->txtUsernameLogin->text();
close();
}
else
QMessageBox::warning(this, "Vocabulary Trainer", "Sorry, your password is incorrect.\nPlease type in the correct password.", QMessageBox::Ok);
}
主要() :
MainWindow w; //Real Window
Login lg(0); //Login Window
lg.set_path(workspace_path);
lg.setModal(true);
if(lg.exec() == QDialog::Rejected)
QMessageBox::critical(0, "rr", "", QMessageBox::Ok);
else
w.show(); //Shows the real window
必ず断られます。