Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.13.1
-
cb1c3528078659c297fb12ea6914978cec1d2614 (qt/qtquickcontrols2/5.14)
Description
When writing partial name of an entry, ComboBox suggests something. When user pressed tab or unfocuses the control, the suggested text remains, but currentIndex and currentText are both still the same as they were before typing something.
It would seem logical that it selects the item it is suggesting by itself when pressing tab or focusing some other item. Or else it should revert back to the current item and clear the text.
Example showing the expected behaviour using widgets:
#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); QObject::connect(comboBox, qOverload<int>(&QComboBox::currentIndexChanged), [=]() { qDebug() << "currentIndex:" << comboBox->currentIndex(); }); hBoxLayout->addWidget(comboBox); auto button = new QPushButton(widget); hBoxLayout->addWidget(button); mainWindow.setCentralWidget(widget); mainWindow.centralWidget()->setLayout(hBoxLayout); mainWindow.resize(400, 400); mainWindow.show(); return app.exec(); }