Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-80546

Not possible to keep an editable ComboBox's Popup open while typing in the TextField

    XMLWordPrintable

Details

    Description

      Qt Widgets supports this via QCompleter::PopupCompletion:

      #include <QtWidgets>
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
      
          QMainWindow mainWindow;
      
          QWidget *widget = new QWidget;
      
          QHBoxLayout *hBoxLayout = new QHBoxLayout(widget);
      
          QComboBox *comboBox = new QComboBox(widget);
          comboBox->setEditable(true);
      
          const QVector<QString> contents = { "Apple", "Banana", "Coconut" };
          auto *model = new QStandardItemModel(contents.size(), 1);
          for (int row = 0; row < contents.size(); ++row) {
              const auto &modelData = contents.at(row);
              auto *item = new QStandardItem(modelData);
              model->setItem(row, 0, item);
          }
          comboBox->setModel(model);
          comboBox->completer()->setCompletionMode(QCompleter::PopupCompletion);
      
          hBoxLayout->addWidget(comboBox);
      
          mainWindow.setCentralWidget(widget);
          mainWindow.centralWidget()->setLayout(hBoxLayout);
      
          mainWindow.resize(400, 400);
          mainWindow.show();
      
          return app.exec();
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tokorpip Tomi Korpipää
            tero.pelkonen Tero Pelkonen
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes