分类: C/C++
2011-08-27 21:06:23
/*
* 标准输入对话框的使用(部分代码)
* Lzy 2011-8-27
*/
#include "widget.h"
#include "ui_widget.h"
#include
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
}
Widget::~Widget()
{
delete ui;
}
void Widget::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void Widget::on_pushButtonName_clicked()
{
bool ok;
QString name = QInputDialog::getText(this,"Name","Input Name",QLineEdit::Normal,"",&ok);
if(ok && !name.isEmpty())
ui->lineEditName->setText(name);
}
void Widget::on_pushButtonAge_clicked()
{
bool ok;
int age = QInputDialog::getInteger(this, "Age", "Input Age", 20, 0, 30, 1, &ok);
if(ok)
ui->lineEditAge->setText(QString::number(age));
}
void Widget::on_pushButton***_clicked()
{
bool ok;
QStringList L;
L << "Man" << "Lad";
QString *** = QInputDialog::getItem(this, "***", "Chose ***", L, 0, false, &ok);
if(ok && !***.isEmpty())
ui->lineEdit***->setText(***);
}
完整代码: 标准输入对话框的使用.rar