Function description:
Enter the correct user name and password in the login interface to log in smoothly. If you make a mistake, you will be prompted to enter the username or password incorrectly.
Show results:
After entering the account password correctly:
Function realization:
It is mainly a slot function of the login button, according to whether ui->lineEdit->text().trimmed() is the desired account and password, then make a judgment, if the input is correct, execute the next step, otherwise a warning message will pop up, The account or password is entered incorrectly.
void Login::on_login_clicked()
{
if(ui->lineEdit->text().trimmed() == tr("admin") && ui->lineEdit_2->text() == tr("admin"))
{
this->hide();
ll.show();
this->close();
}
else
{
QMessageBox mess(QMessageBox::Information,tr("Warning!"),tr("Wrong user name or password!"));
mess.setWindowIcon(QIcon(":/main/logo"));
mess.exec();
// 清空输入框内容
ui->lineEdit->clear();
ui->lineEdit_2->clear();
//光标定位
ui->lineEdit->setFocus();
}
}
Reference:
https://blog.csdn.net/nanfeibuyi/article/details/79959043
https://blog.csdn.net/qq_16488989/article/details/109024570