Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QCompleter with keyboard accents
Forum Updated to NodeBB v4.3 + New Features

QCompleter with keyboard accents

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 358 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Jonas KvingeJ Offline
    Jonas KvingeJ Offline
    Jonas Kvinge
    wrote on last edited by
    #1

    Hi,

    When using a QLineEdit with QCompleter, it is not possible to use keyboard accents while the popup with the suggested text is visisble.
    Is there a workaround for this, or is it a Qt bug?

    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.

    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
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Which distribution are you using ?
      Which locale is configured ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Jonas KvingeJ Offline
        Jonas KvingeJ Offline
        Jonas Kvinge
        wrote on last edited by
        #3

        I'm using openSUSE tumbleweed.
        The locale is set to "en_US.UTF-8" with English US keyboard.
        But I've tested multiple keyboard layouts.
        So it works for you?

        1 Reply Last reply
        0
        • F Offline
          F Offline
          FrontierPsycho
          wrote on last edited by
          #4

          Having the same issue (in fact I reported it to Johan) on Debian unstable with Qt 5.15.2, my locale is set to sv_SE.UTF-8 but I encountered the problem while typing with a greek keyboard layout.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved