diff --git a/autotests/kcombobox_unittest.cpp b/autotests/kcombobox_unittest.cpp --- a/autotests/kcombobox_unittest.cpp +++ b/autotests/kcombobox_unittest.cpp @@ -45,6 +45,10 @@ w.addItem(QStringLiteral("Hello world")); QVERIFY(w.lineEdit()); QVERIFY(qobject_cast(w.lineEdit())); + auto lineEdit = w.lineEdit(); + // set editable again, don't recreate the line edit + w.setEditable(true); + QCOMPARE(w.lineEdit(), lineEdit); // KLineEdit signals QSignalSpy qReturnPressedSpy(w.lineEdit(), SIGNAL(returnPressed())); QSignalSpy kReturnPressedSpy(w.lineEdit(), SIGNAL(returnPressed(QString))); diff --git a/src/kcombobox.cpp b/src/kcombobox.cpp --- a/src/kcombobox.cpp +++ b/src/kcombobox.cpp @@ -389,6 +389,10 @@ void KComboBox::setEditable(bool editable) { + if (editable == isEditable()) { + return; + } + if (editable) { // Create a KLineEdit instead of a QLineEdit // Compared to QComboBox::setEditable, we might be missing the SH_ComboBox_Popup code though...