Important: Please read the Qt Code of Conduct -

Using QCompleter with a virtual keypad

  • The behavior of QCompleter is preventing me from using it with the virtual keypad I have created. When the QCompleter's popup is showing, a press on the keypad closes the completer, and a second press is required to enter a character. Is there any way to change the behavior of the completer so that clicks outside of the popup window are ignored?

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    How are you using it exactly ?

  • I'm using it with a QLineEdit in PopupCompletion mode. Next to the QLineEdit I have a button that forces the popup to show with all possible completions. The button part of it was the functionality I was really after. The fact that it pops up while the user is typing would be a nice touch if it worked correctly, but it's not a requirement I have.

  • Lifetime Qt Champion

    How are you implementing your virtual keypad ?

    This article might be interest for a more integrated solution.

  • I'm not sure how a re-implementation of my keypad will solve the issue with the completer popup.

  • Lifetime Qt Champion


    if your goal is to just make it stay open, you can do the following

    class openCompleter : public QCompleter {
      openCompleter(QObject* parent) : QCompleter(parent) {}
      virtual ~openCompleter() override {}
      bool eventFilter(QObject* o, QEvent* e) override {   
        if ( e->type() == QEvent::Type::MouseButtonPress) {
            qDebug() << " event is hide: " << o->metaObject()->className();
            return false;
        return QCompleter::eventFilter(o, e);

    and just use openCompleter and not QCompleter.
    However, you will need some way for user to cancel the popup then.

  • Lifetime Qt Champion

    I don't know how you implemented your virtual keypad, the article I linked to proposes an implementation that integrates directly with Qt's input system.

Log in to reply