Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-92464

QCompleter breaking use of keyboard accents

XMLWordPrintable

    • Linux/X11
    • f83ea8962 (dev), d06debf22 (tqtc/lts-6.2), 3992857b8 (6.5), 0a981bd9d (6.6)

      When using a QLineEdit with QCompleter, it is not possible to use keyboard accents while the popup with the suggested text is visible. It works however if you click away the popup, but this can be annoying for the user.

      I made a simple program here to demonstrate it: https://github.com/jonaski/completertest
      When you enter test, the popup is shown, it is not possible to enter "ALT GR" + ; + a to get 'รก', you instead get a regular character 'a'.

      I get the same result with both Qt 6.0.3 and Qt 5.15.2. It's on Linux/X11.

      I'm using openSUSE tumbleweed.
      The locale is set to "en_US.UTF-8" with English US keyboard.
      But I've tested multiple locales and keyboard layouts.

      Code:

      #include <QMainWindow>
      #include "mainwindow.h"
      #include "completer.h"
      
      MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui_(new Ui_MainWindow) {
      
        ui_->setupUi(this);
      
        show();
        Completer *completer = new Completer();
        ui_->lineedit->setCompleter(completer);
      
      }
      
      MainWindow::~MainWindow() { delete ui_; }
      
      
      #ifndef MAINWINDOW_H
      #define MAINWINDOW_H
      
      #include <QMainWindow>
      #include "ui_mainwindow.h"
      
      class MainWindow : public QMainWindow {
        Q_OBJECT
      
       public:
        explicit MainWindow(QWidget *parent = nullptr);
        ~MainWindow();
      
       private:
        Ui_MainWindow *ui_;
      
      };
      
      #endif // MAINWINDOW_H
      
      #include <QCompleter>
      #include "completer.h"
      
      Completer::Completer() {
        setModel(new CompleterModel());
        setCaseSensitivity(Qt::CaseInsensitive);
      }
      
      Completer::~Completer() {}
      
      CompleterModel::CompleterModel() {
        setStringList(QStringList() << "Test1" << "Test2");
      }
      
      CompleterModel::~CompleterModel() {}
      
      #ifndef COMPLETER_H
      #define COMPLETER_H
      
      #include <QCompleter>
      #include <QStringListModel>
      
      class Completer : public QCompleter {
        Q_OBJECT
      
       public:
        explicit Completer();
        ~Completer();
      
       private:
      
      };
      
      class CompleterModel : public QStringListModel {
        Q_OBJECT
      
       public:
        explicit CompleterModel();
        ~CompleterModel();
      
       private:
      
      };
      
      #endif // COMPLETER_H
      

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            liaqi Liang Qi
            jonaski Jonas Kvinge
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes