How to find a letter in full word by using QCompleter for QLineEdit Auto Completion?



  • Hi...

    I have a QLineEdit, I have to set the auto completion for the QLineEdit, So i tried it using QCompleter. I have a QStringList of 5 items in it (eg. America, Africa, Canada, England, France ). The QCompleter's auto completion is based on the Prefix (first character) of the String List.

    Suppose if i type "C" in the QLineEdit, then only Canada is suggested by the QCompleter.

    But i want to display all the items which has the Character "C" in the string list. That is, my suggestion list should look like, America, Africa, Canada and France. which has the character C in it. How to find the Letter in a full word by using QCompleter?.
    Or is there any other ways of doing it? Please give your suggestions.

    @#include <QLineEdit>
    #include <QCompleter>

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

    QStringList wordList;
    wordList << "America" << "Africa" << "Canada" << "England" <<"France";
    
    QLineEdit *lineEdit = new QLineEdit(this);
    
    QCompleter *completer = new QCompleter(wordList,this);
    completer->setCaseSensitivity(Qt::CaseInsensitive);
    lineEdit->setCompleter(completer);
    

    }

    LECompleter::~LECompleter()
    {
    delete ui;
    }
    @

    Thanks & Regards



  • What you want is very similar to "this":http://www.qtcentre.org/archive/index.php/t-23518.html



  • Custom completer seems to be the best way. I hope this thread will be helpful: http://www.qtcentre.org/archive/index.php/t-23518.html


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.