PDA

View Full Version : More completitions per lineedit?



jiveaxe
24th January 2012, 17:39
I'm asking if it is possible to call multiple times a completer on a QLineEdit after inserting a separator character. Let me explain with an example:

Let's say we have


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

QLineEdit *lineEdit = new QLineEdit(this);

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

typing on the lineedit pops the completer; I choose one of the entry in the list, then type a delimeter character like ',' and start typing again triggering again the completer; here a mockup

http://img546.imageshack.us/img546/4703/finaleht.png (http://imageshack.us/photo/my-images/546/finaleht.png/)

I dunno if a similar implementation was already adopted by any app; if so, please tell me which one.

Very thanks

wysota
24th January 2012, 19:54
You need a hierarchical model containing all permutations of the words and reimplement splitPath() using the separator of your choice.

jiveaxe
24th January 2012, 22:50
Since my list will contain ~4K elements, do you think that the method you suggest is still applicable?

Thanks

wysota
24th January 2012, 22:51
Yes, it's applicable. Of course you have to generate the combinations on the fly instead of statically inserting all elements into the model.