Important: Please read the Qt Code of Conduct -

Custom QComplete

  • Hello Guys,

    I use the QCompleter from this example

    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:


    What is wrong with this example?

    Thanks for help!

  • Lifetime Qt Champion

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

  • 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....

  • Lifetime Qt Champion

    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.

  • Do you know why the auto completer do this?

Log in to reply