PDA

View Full Version : FAster approach for Completetion



codeman
19th July 2010, 19:39
Hello Friends,

I experiment with the standard approach for implementing QCompleter in a QLineEdit.
But when the wordlist grows up to 20000 or more the delay before the popup widget for completetion comes ist to long.

Is there another aproach for implementing completetion with big amount of words?

Lykurg
19th July 2010, 20:16
Are you using a QStringListModel? If so, create a SQLite database in the memory, or if the wordlist wont change on your disk, and use that with a QSqlTableModel. This will speed up the process.

wysota
20th July 2010, 02:45
Someone should really write a completer class based on a suffix (or prefix) tree...

codeman
20th July 2010, 22:02
I use this:



QCompleter *completer = new QCompleter(qstrL_mylist, this);
completer->setCompletionMode(QCompleter::PopupCompletion);
qle_myLineEdit->setCompleter(completer);

Lykurg
20th July 2010, 22:10
then, as told, try to use a sqlite database.

codeman
20th July 2010, 22:23
so now I implement this one:



QSqlTableModel *model = new QSqlTableModel;
model->setTable("mytable");
model->select();
QCompleter *completer = new QCompleter(model, this);
completer->setCompletionMode(QCompleter::PopupCompletion);
completer->setCompletionColumn(0);
qle_myLineEdit->setCompleter(completer);


now the delay is ca. 0.3 seconds by 40000 words feels ok or exists there a better approach??

wysota
20th July 2010, 22:51
You can implement your own completer class based on Patricia trie and optionally populated in a worker thread with caching completion traces (so that removing the last character of completion prefix doesn't cause the completion list to be rebuilt). That's pretty much maximum you can squeeze from a completer mechanism.

codeman
22nd July 2010, 19:14
Patricia trie ???????

Lykurg
22nd July 2010, 19:49
Patricia trie ???????

Google is your friend: http://en.wikipedia.org/wiki/Radix_tree!