void InputDlg::slotName()

来源:互联网 发布:帝王三国单机无需网络 编辑:程序博客网 时间:2024/06/05 20:44
void InputDlg::slotName(){                                  bool ok;    QString name = QInputDialog::getText(this,tr("User Name"),    tr("Please input new name:"),QLineEdit::Normal,nameLabel->text(),&ok);      if(ok && !name.isEmpty())    nameLabel->setText(name);}                                                                                                                       void InputDlg::slotSex()                    {                 QStringList list;    list << tr("male") << tr("female");    bool ok;    QString sex = QInputDialog::getItem(this,tr("Sex"),    tr("Please select sex:"),list,0,false,&ok);    if (ok)    sexLabel->setText(sex);}                                                                                                                       void InputDlg::slotAge()                     {                                 bool ok;                      int age = QInputDialog::getInteger(this,tr("User Age"),    tr("Please input age:"),ageLabel->text().toInt(),0,150,1,&ok);      if(ok)      ageLabel->setText(QString(tr("%1")).arg(age));}void InputDlg::slotStature()                     {                                 bool ok;    double d = QInputDialog::getDouble(this,tr("Stature"),    tr("Please input stature:"),175.00,0,230.00,1,&ok);      if(ok)    statureLabel->setText(QString(tr("%1")).arg(d));}

原创粉丝点击