Custom QComplete



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


  • Qt Champions 2017

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


  • Qt Champions 2017

    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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.