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. Custom QComplete
Qt 6.11 is out! See what's new in the release blog

Custom QComplete

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 1.4k Views 1 Watching
  • 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.
  • KampiK Offline
    KampiK Offline
    Kampi
    wrote on last edited by
    #1

    Hello Guys,

    I use the QCompleter from this example

    http://doc.qt.io/qt-5/qtwidgets-tools-customcompleter-textedit-cpp.html

    with two modifications:

    1. Use completionPrefix.length() < 1 instead of completionPrefix.length() < 3
    2. Add a custom list
    QAbstractItemModel *MainWindow::modelFromFile(const QString& fileName)
    {
            QStringList words = {"Cat", "dog", "fish", "rat", "bird", "lion", "elephant"};
    
        return new QStringListModel(words, completer);
    }
    

    If I start the programm, the first two words ("Cat" and "dog") are working pretty fine, but I don´t get any completition for the third word and so on:

    0_1473167935309_Unbenannt.png

    What is wrong with this example?

    Thanks for help!

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      hi
      i tried your code
      ( not completionPrefix as didnt see it ) but your list
      and it does work with fish using ctrl+e ?

      1 Reply Last reply
      0
      • KampiK Offline
        KampiK Offline
        Kampi
        wrote on last edited by
        #3

        Hell mrjj,

        thank you for your answer,
        Yes, it works pretty fine with CTRL + E.
        I mean the case when I type in "f", "i". For the word "cat" the auto complete window appears (see picture)

        0_1473231070975_Auto complete(1).png

        But not for some other words like "lion"

        0_1473231127830_Auto complete(2).png

        I don´t really understand this behavior....

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Sorry, the upload picture is broken so others cant seem them.

          I re-tested and yes, its a bit odd that only some can auto pop.

          1 Reply Last reply
          0
          • KampiK Offline
            KampiK Offline
            Kampi
            wrote on last edited by
            #5

            Do you know why the auto completer do this?

            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