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. Words to completion
QtWS25 Last Chance

Words to completion

Scheduled Pinned Locked Moved General and Desktop
13 Posts 3 Posters 3.4k 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.
  • R Offline
    R Offline
    Ruzik
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZapB
      wrote on last edited by
      #2

      Have you tried debugging the example to see if the file gets loaded correctly?

      Nokia Certified Qt Specialist
      Interested in hearing about Qt related work

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Ruzik
        wrote on last edited by
        #3

        Yes i am compiled example with my file and there complet only first word in the list - "top"

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          ZapB
          wrote on last edited by
          #4

          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.

          Nokia Certified Qt Specialist
          Interested in hearing about Qt related work

          1 Reply Last reply
          0
          • R Offline
            R Offline
            Ruzik
            wrote on last edited by
            #5

            Yes, I tested it - file read correctly.
            I noticed the following feature - if in the standart file with words(file, witch example use by default) wrie some word then program doesnt worked, i think that problem in the sign of "a new line" or other separator

            1 Reply Last reply
            0
            • R Offline
              R Offline
              Ruzik
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              • R Offline
                R Offline
                Ruzik
                wrote on last edited by
                #7

                Help me, plaease, i am a beginner in the Qt

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andre
                  wrote on last edited by
                  #8

                  Please practise some patience. Allow for at least 24 hours before "kicking" your topic.

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    Ruzik
                    wrote on last edited by
                    #9

                    Please excuse me, of course I'll wait as much as you want, I just thinking that you forgot about my problem.
                    And once again many thanks for your help!

                    1 Reply Last reply
                    0
                    • Z Offline
                      Z Offline
                      ZapB
                      wrote on last edited by
                      #10

                      Not forgotten about you. We have day jobs too and do need some personal time too sometimes ;-)

                      I'm just back from a swim. I'll try to take a look at it tonight after I've had some food.

                      Nokia Certified Qt Specialist
                      Interested in hearing about Qt related work

                      1 Reply Last reply
                      0
                      • Z Offline
                        Z Offline
                        ZapB
                        wrote on last edited by
                        #11

                        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.

                        Nokia Certified Qt Specialist
                        Interested in hearing about Qt related work

                        1 Reply Last reply
                        0
                        • Z Offline
                          Z Offline
                          ZapB
                          wrote on last edited by
                          #12

                          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.

                          Nokia Certified Qt Specialist
                          Interested in hearing about Qt related work

                          1 Reply Last reply
                          0
                          • R Offline
                            R Offline
                            Ruzik
                            wrote on last edited by
                            #13

                            Many thinks for your help, it is worked!

                            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