Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to find a letter in full word by using QCompleter for QLineEdit Auto Completion?

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.9k Views
  • 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 Offline
    M Offline
    Macro
    wrote on last edited by
    #1

    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
    0
    • P Offline
      P Offline
      prady_80
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bodzio131
        wrote on last edited by
        #3

        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
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved