Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    General and Desktop
    3
    3
    1662
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      Macro last edited by

      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

      1 Reply Last reply Reply Quote 0
      • P
        prady_80 last edited by

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

        1 Reply Last reply Reply Quote 0
        • B
          bodzio131 last edited by

          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

          1 Reply Last reply Reply Quote 0
          • First post
            Last post