Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.7.3
-
None
Description
Consider the following example:
#include <QApplication> #include <QComboBox> #include <QLineEdit> int main(int argc, char **argv) { QApplication app(argc, argv); QComboBox cb; cb.setFixedWidth(200); cb.setEditable(true); cb.addItem(QStringLiteral("Single Entry")); cb.setEditText(QStringLiteral("Second Entry")); cb.lineEdit()->selectAll(); QObject::connect(cb.lineEdit(), &QLineEdit::returnPressed, &app, [&cb]() { qWarning("->%s", qPrintable(cb.currentText())); }); cb.show(); return app.exec(); }
Here, a QComboBox is created with an initial single entry. Then the edit text is set to something different and selected.
Observed: On hitting Return you see the initial single entry printed out on the console and the combobox shows this entry.
Expected: On hitting Return you see the set edit text printed out on the console and the text in the combobox does not change (and perhaps the selection should stay as in a normal QLineEdit).
Fun fact: If you do not select the text, the combobox behaves as expected.