输入内容, 列出可选的项: QComboBox

时间:2014-05-12 08:12:35   收藏:0   阅读:243
bubuko.com,布布扣
#include "widget.h"
#include "ui_widget.h"
#include <QtGui/QCompleter>
#include <QStringList>

Widget::Widget(QWidget *parent)
    : QWidget(parent), ui(new Ui::Widget) {
    ui->setupUi(this);

    QStringList strings;
    strings << "Biao" << "Biao Huang" << "Mac" << "MacBook" << "MacBook Pro" << "Mac Pro";
    completer = new QCompleter(strings, this);

    ui->comboBox->clear();
    ui->comboBox->addItems(strings);
    ui->comboBox->setEditable(true);
    ui->comboBox->setCompleter(completer);
}

Widget::~Widget() {
    delete ui;
    delete completer;
}
bubuko.com,布布扣

 

输入内容, 列出可选的项: QComboBox,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!