tags:

views:

789

answers:

2

Hello,

Is there any way to have the QCompleter to act like an autocomplete for multiple words?

Someone has any ideia how to do it?

Thanks

+3  A: 

I don't know if I understand correctly:

QStringList wordList;
wordList << "alpha and beta" << "omega" << "omicron" << "zeta";

QCompleter *completer = new QCompleter(wordList, this);
completer->setCaseSensitivity(Qt::CaseInsensitive);

QLineEdit *lineEdit = new QLineEdit(this);
lineEdit->setCompleter(completer);

If you type alp then you get the completion "alpha and beta" which is more than one word. There is no limit.

Update after clarifications:

Seems that what is requested is starting a new autocompletion after a delimiter value. In the current case this delimiter will be a space. An equivalent example would be the tree model completer from the Qt examples. This example illustrates how to solve the same situation.

Yorgos Pagles
A: 

YoP,

What if i need to make this QLineEdit a multiple choice, like tha tag field when you are posting a new Question where?

Thanks

mileschet
For clarifications it is suggested that you edit your original question ;-)
Yorgos Pagles