QT密码


QRegExp rx("([A-Z] | (a-z))*$");
QValidator *validator = new QValidator(rx,this);
QLineEdit *le = new QLineEdit;
le->setValidator(validator);
QRegExp rx("([A-Z] | (a-z))*$");
QValidator *validator = new QValidator(rx,this);
QLineEdit *le = new QLineEdit;

le->setValidator(validator);

    lineedit=new QLineEdit(tool3);
    lineedit->setEchoMode(QLineEdit::Password);
    lineedit->setValidator(new QIntValidator(lineedit));
    lineedit->setMaxLength(6);
    connect(lineedit,SIGNAL(returnPressed()),this,SLOT(codeSubmit()));
    lineedit->setGeometry(20,40,100,20);

void KeyWidget::codeSubmit()
{
    QString valueStr=lineedit->text();
    int valueInt=valueStr.toInt();
    if(valueInt==999999)
    {
        qDebug()<<"you are right";
        stackbox->setCurrentIndex(1);
        labelpt1->setText(QString(tr("密码正确!")));
    }
    else{
        labelpt1->setText(QString(tr("密码输入错误!")));
    }
    lineedit->clear();
}


你可能感兴趣的:(qt,Signal)