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

QLineEdit issues with Qwerty keyboard events from right and left arrow keys

XMLWordPrintable

    • 81351f2c6f9a939e4c34cb3be6280d396c21941f

      Cursor position is not updated visually on the QLineEdit using Left and Right arrow keys with a Qwerty keypad. I have found this issue on N97 and S^3 devices. So when a text say 123456* where (* = cursor) is typed on the QLineEdit and use the left arrow key, cursor position still stays at 123456*. Again press left arrow key and cursor position is changed to 12345*6 but the actual cursor pos should have been at 1234*56 and now on pressing backspace, it deletes 4 and so on. So it seems like the cursor positon is not updated correctly. I have tried a very simple example for this as below.

      .h

      #include <QMainWindow>
      #include <QLabel>
      #include <QLineEdit>
      
      namespace Ui {
          class MainWindow;
      }
      
      class MainWindow : public QMainWindow
      {
          Q_OBJECT
      
      public:
          explicit MainWindow(QWidget *parent = 0);
          ~MainWindow();
      
      private slots:
          void slotCursorPositionChanged(int,int);
      
      private:
          Ui::MainWindow *ui;
          QLabel*label1;
          QLabel*label2;
          QLineEdit* q;
      };
      

      .cpp


      #include "mainwindow.h"
      #include "ui_mainwindow.h"
      
      #include <QDebug>
      
      MainWindow::MainWindow(QWidget *parent) :
          QMainWindow(parent),
          ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
      
          q=new QLineEdit(this);
          q->setGeometry(50,50,100,50);
          connect(q,SIGNAL(cursorPositionChanged(int,int)),SLOT(slotCursorPositionChanged(int,int)));
      
          label1=new QLabel(this);
          label1->setGeometry(50,100,100,50);
      }
      
      void MainWindow::slotCursorPositionChanged(int a,int b)
      {
          qDebug() << "cursorPos" << a << " " << b;
          label1->setText(QString("Old:%1 New:%2").arg(a).arg(b));
          q->setCursorPosition(b);
          q->update(); 
      }
      
      MainWindow::~MainWindow()
      {
          delete ui;
      }
      

        1. leftkey.zip
          34 kB
          Johannes Nynäs
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            e0348803 Miikka Heikkinen
            reshmas Reshma Sandeep Das
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes