You Are Here:

Community: Wiki

This page was last modified on 31 October 2009, at 14:08.

How To use QCompleter

From Forum Nokia Wiki



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

Overview

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

Preconditions

Various Function

  • This property holds the case sensitivity of the matching.
completer->setCaseSensitivity(Qt::CaseInsensitive);
  • This property holds how the completions of a specific words are provided to the user.
completer->setCompletionMode(QCompleter::InlineCompletion);
completer->setCompletionMode(QCompleter::QCompleter::UnfilteredPopupCompletion); 

Image:Com.JPG

  • This property holds the item role to be used to query the contents of items for matching.
completer->setCompletionRole(3);


Source Code

#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();
}


Screenshot

More about Qcompleter:Qcompleter

Image:Completer001.jpg

More about Qcompleter:Qcompleter

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fTalkE3aE4cargeE5fscreenE5fsaverX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ
RDF Facets: qfnZuserE5FtagQSxE71completerX