[英]Qt When will the dialog return QDialog::Rejected
我有麻煩了。 我有一個QDialog作為登錄表單。 當我登錄時,表單關閉,我的主窗口將出現。 我的登錄很好但是當它關閉時它會返回QDialog :: Rejected。
我該怎么做才能阻止QDialog :: Rejected的返回? 什么時候它甚至會返回QDialog ::拒絕?
我登錄時的代碼:
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);
}
main():
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
它總是會被拒絕。
嘗試調用done(QDialog::Accepted);
而是close();
在Login::on_cmdLogin_clicked()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.