Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.5.1
-
None
Description
Usage of QComplete with PopupCompletion completion mode leads to duplicate calling of activated() signal in parent QComboBox widget, when user chooses an auto-complete option in popup list and not in QComboBox itself.
Here's a minimal reproducing code:
//main.cpp #include <QApplication> #include "form.h" int main(int argc, char** argv) { QApplication app(argc, argv); Form form; form.show(); return app.exec(); } // form.h #ifndef FORM_H #define FORM_H #include <QWidget> class Form : public QWidget { Q_OBJECT public: Form(); private slots: void test_activated(int index); }; #endif // FORM_H // form.cpp #include "form.h" #include <QDebug> #include <QComboBox> #include <QCompleter> Form::Form() { resize(200, 50); QComboBox* p = new QComboBox(this); p->setEditable(true); p->setCompleter(new QCompleter(p)); p->completer()->setCaseSensitivity(Qt::CaseInsensitive); p->setInsertPolicy(QComboBox::NoInsert); connect(p, SIGNAL(activated(int)), this, SLOT(test_activated(int))); p->completer()->setCompletionMode(QCompleter::PopupCompletion); p->completer()->setModel(p->model()); QStringList items; items << "" << "Hello" << "Hair" << "World"; p->addItems(items); } void Form::test_activated(int index) { qDebug() << "Form::test_activated, index:" << index; }
To reproduce:
1. Type "H" and choose any completion variant with down arrow and Enter.
2. Notice something like:
Form::test_activated, index: 1 Form::test_activated, index: 1
appearing at once in the output.
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-51889 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
153588,3 | Fix QCompleter not to send activated() signal with no user action | 5.6 | qt/qtbase | Status: NEW | -2 | 0 |
203230,7 | QCompleter: Send activated() signal only once on return key | 5.9 | qt/qtbase | Status: MERGED | -2 | 0 |