如何使用QCompleter
答案:1 悬赏:70 手机版
解决时间 2021-04-02 07:47
- 提问者网友:嗝是迷路的屁
- 2021-04-01 23:14
如何使用QCompleter
最佳答案
- 五星知识达人网友:愁杀梦里人
- 2021-04-02 00:20
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *win=new QWidget();
QHBoxLayout *lay=new QHBoxLayout();
QStringList wordList;
wordList <<"alpha"<<"omega"<<"omicron"<<"zeta"<<"america"<<"orion"<<"amit"<<"Odssey";
QLabel *lbl = new QLabel("Select");
QLineEdit *lineEdit = new QLineEdit();
lbl->setBuddy(lineEdit);
QCompleter *completer = new QCompleter(wordList);
completer->setCaseSensitivity(Qt::CaseInsensitive);//大小写匹配
//completer->setCompletionMode(QCompleter::InlineCompletion);//完整的匹配Inline (1)
completer->setCompletionMode(QCompleter::PopupCompletion); //匹配以弹出式显示 (2)
//completer->setCompletionMode(QCompleter::UnfilteredPopupCompletion);//将全部信息以弹出式显示
//completer->setCompletionRole(0); //设置ItemDataRole
lineEdit->setCompleter(completer);
lay->addWidget(lbl);
lay->addWidget(lineEdit);
win->setLayout(lay);
win->show();
{
QApplication a(argc, argv);
QWidget *win=new QWidget();
QHBoxLayout *lay=new QHBoxLayout();
QStringList wordList;
wordList <<"alpha"<<"omega"<<"omicron"<<"zeta"<<"america"<<"orion"<<"amit"<<"Odssey";
QLabel *lbl = new QLabel("Select");
QLineEdit *lineEdit = new QLineEdit();
lbl->setBuddy(lineEdit);
QCompleter *completer = new QCompleter(wordList);
completer->setCaseSensitivity(Qt::CaseInsensitive);//大小写匹配
//completer->setCompletionMode(QCompleter::InlineCompletion);//完整的匹配Inline (1)
completer->setCompletionMode(QCompleter::PopupCompletion); //匹配以弹出式显示 (2)
//completer->setCompletionMode(QCompleter::UnfilteredPopupCompletion);//将全部信息以弹出式显示
//completer->setCompletionRole(0); //设置ItemDataRole
lineEdit->setCompleter(completer);
lay->addWidget(lbl);
lay->addWidget(lineEdit);
win->setLayout(lay);
win->show();
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯