Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

    Solved How to make input field with list under it contain suggestions?

    General and Desktop
    2
    5
    370
    Loading More Posts
    • 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.
    • ?
      A Former User last edited by

      as you can see from this photo I'm trying to make a input field with suggestions under it in a list
      0_1534024347900_anigif_enhanced-19782-1399666227-9.gif
      can anyone know how to do it

      1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by mrjj

        Hi and welcome
        You can use QCompleter
        http://doc.qt.io/qt-5/qtwidgets-tools-completer-example.html
        here it uses files but list can be anything.

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

        http://doc.qt.io/qt-5/qcompleter.html

        ? 1 Reply Last reply Reply Quote 2
        • ?
          A Former User @mrjj last edited by

          @mrjj is there a way to use QCompleter in form design

          mrjj 1 Reply Last reply Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion @Guest last edited by mrjj

            @davidlabib
            nope as its not visual.
            But you can assign it to Edit you have placed on form. (UI)
            so almost yes.
            All it takes is

            (after setupUI())
            
            QStringList wordList;
            wordList << "alpha" << "omega" << "omicron" << "zeta";
            QCompleter *completer = new QCompleter(wordList, this);
            completer->setCaseSensitivity(Qt::CaseInsensitive);
            ui->lineEdit->setCompleter(completer);
            
            ? 1 Reply Last reply Reply Quote 1
            • ?
              A Former User @mrjj last edited by

              @mrjj thanks a lot

              1 Reply Last reply Reply Quote 0
              • First post
                Last post