QComboBox with QCompleter: multiple FocusIn event Issue

  • Whenever popUp of editable QComboBox gets closes (no match found in popUp view) FocusIn event gets triggered in eventfilter. Below id my code snippet:

    MyComboBox::MyComboBox(QWidget *parent):QComboBox(parent)
    bool MyComboBox::eventFilter(QObject *target, QEvent *event)
        if (target == this)
            if(event->type() == QEvent::FocusOut) {
                            qDebug()<<"22 Focus OUT event ::"<<this;
            else if(event->type() == QEvent::FocusIn) {
                            qDebug()<<"11 Focus IN event ::"<<this;
        return QWidget::eventFilter(target,event);

    in MainWindow where I am instantiating it:

    MyComboBox *combo = new MyComboBox(this);
        QCompleter *completer1 = new QCompleter(this);
        for (int var = 1; var < 100; ++var) {

    My requirement is if user first entered into MyComboBox (either by click or by tabFocus change) he can directly start writing text in lineedit and QCompleter popup will get shown. So I write this functionality in foucsIn event lineEdit()->selectAll();
    But issue is if lineedit text doesn't matched to any text in poupup view, then popUp view gets closed and again FocusIn event gets called and select all text inside lineedit.