I'm making a form where a user submits their own name, username, etc. but the username must be unique, so it throws up a QMessageBox error if the chosen username is already in use.
If that lineEdit is not first in the tab order, how do you snap to that lineEdit after the click event?
{
UserDB userconn;
QString name,username,password,number,userid,userid2;
name=ui->lineEdit_firstlastname->text();
username=ui->lineEdit_username->text();
password=ui->lineEdit_password->text();
number=ui->lineEdit_phonenumber->text();
userid="Admin";
userid2="User";
QByteArray prehash;
prehash.append(password);
QString hashword = QString(QCryptographicHash::hash(prehash,QCryptographicHash::Md5).toHex());
QSqlQuery qry2;
qry2.prepare("select * from user where username='"+username+"'");
if(qry2.exec())
{
int count=0;
while(qry2.next())\
{
count++;
}
if(count==1)
{
QMessageBox::critical(this,tr("Error!"),tr("Choose a different username!"));
ui->lineEdit_username->setText("");
}
else....
{
/*
here, if the user submits a duplicate username, a
QMessageBox pops up telling the user to choose a
different username, and the focus returns to either the
pushButton or to the last lineEdit before the user
pressed Enter, and in this case, I'd like to return the
focus to that lineEdit that needs to be edited.
*/
}
}
}