Words to completion
-
Hellow, there is example "custom completer" and there is a txt file, where write words to completion, i change file on the file with my words, and program stopped to complet. Among all words program complete only first word - top
"My text file":http://www.forum.crossplatform.ru/index.php?act=attach&type=post&id=1371
What am I doing wrong, i redaction file in the Windows notebook and in the Notepad++ with "\n" - program doesnt worked
Thanks in advance! And sorry for my vary bad english! -
That's not what I asked. I asked if you had executed the application in a debugger and stepped through it line by line where the file is loaded and actually inspected the affected variables in the debugger to make sure they contain the contents of the entire file.
-
-
I find in the code of textEdit interesting string:
static QString eow("~!@#$%^&*()_+{}|:"<>?,./;'[]\-="); // end of word
How i can think it is mean that after all words in the list i must write one of the following signs, i am try but program also dont work and in the example list there are no some signs after words -
OK I can reproduce the problem - even with a trimmed down version of your wordslist.txt file that removes anything other than [a-z]. I also tried converting line endings to unix style to no avail.
It appears as if the QStringListModel is being correctly populated from the file so th eproblem must lie deeper.
I'll need to dig into Qt itself to see what is going wrong so it may take me a little while.
-
OK forget that. I've figured it out. The problem is you are breaking an assumption of that example. In the constructor of the custom completer example you'll see this line of code:
@
completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel);
@This tells the app that the supplied word list is already sorted which allows the completer to make some optimisations when searching for matching completions (I would imagine it uses a bisection search rather than linear search but I have not checked).
Your word list is not sorted which breaks that pre-condition. To fix it you can either
Sort your wordlist so that it matches the above condition (ie sorted case insensitively)
Change the example to use QCompleter::UnsortedModel
I recommend option 1. When I did this (using the sort command under linux) it worked perfectly.