| ID | ... | Creation date | 17 March 2009 |
| Platform | S60 3rd Edition FP2, S60 5th Edition | Tested on devices | S60 Emulator |
| Category | Qt for S60 | Subcategory | Application |
| Keywords (APIs, classes, methods, functions): QLineEdit,QStringList,QCompleter |
You can use QCompleter to provide auto completions in some of Qt widget, such as QLineEdit and QComboBox.
When the user starts typing a word, QCompleter suggests possible ways of completing the word, based on a word list.QCompleter
This example makes the use of following classes
QCompleter-Provides completions based on an item model
QStringList-Provides a list of strings
completer->setCaseSensitivity(Qt::CaseInsensitive);
completer->setCompletionMode(QCompleter::InlineCompletion); completer->setCompletionMode(QCompleter::QCompleter::UnfilteredPopupCompletion);
completer->setCompletionRole(3);
#include <QtGui/QApplication>
#include "qcomplimentwidget.h"
#include<QStringList>
#include<QLineEdit>
#include<QCompleter>
#include<QHBoxLayout>
#include<QWidget>
#include<QLabel>
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); //Make caseInsensitive selection
//completer->setCompletionMode(QCompleter::InlineCompletion); //Used to enable in line searching
//completer->setCompletionRole(3);
lineEdit->setCompleter(completer);
lay->addWidget(lbl);
lay->addWidget(lineEdit);
win->setLayout(lay);
win->showMaximized();
win->setStyleSheet("* { background-color:rgb(199,147,88); padding: 7px ; color:rgb(255,255,255)}");
return a.exec();
}
More about Qcompleter:Qcompleter
More about Qcompleter:Qcompleter
No related wiki articles found