Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7563327
  • 博文数量: 961
  • 博客积分: 15795
  • 博客等级: 上将
  • 技术积分: 16612
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-07 14:23
文章分类

全部博文(961)

文章存档

2016年(1)

2015年(61)

2014年(41)

2013年(51)

2012年(235)

2011年(391)

2010年(181)

分类: 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   

阅读(1674) | 评论(0) | 转发(3) |
给主人留下些什么吧!~~