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

Android's virtual keyboard "OK" button must not accept the QDialog

    XMLWordPrintable

    Details

    • Platform/s:
      Android
    • Commits:
      e5686b35f07ea54f59e81d04a054bd832bee69b9 (qt/qtbase/dev) 05408a4e5fd1c411371983d75e361f23597cf4c7 (qt/tqtc-qtbase/5.15)
    • Sprint:
      2022wk34FOQtforAndroid

      Description

      Running an app on Android, I have a QDialog with a few edit fields (`QLineEdit`) and a `QDialogButtonBox`. When user enters text in one of my `QLineEdit`, then press "OK" button from Android virtual keyboard, it accepts the dialog (as if I clicked "OK" on the `QDialogButtonBox`), while user expects to commit the text to the currently selected edit field so that he can move to the next one...

      This is really annoying and makes it almost impossible to deploy apps with dialog requesting many user inputs. A workaround would really be appreciated.

      Sample program:

      #include <QApplication>
      #include <QDialog>
      #include <QDialogButtonBox>
      #include <QPushButton>
      #include <QVBoxLayout>
      #include <QLineEdit>
      
      class MyDialog : public QDialog
      {
      public:
          MyDialog()
          {
              QVBoxLayout* layout = new QVBoxLayout(this);
              layout->addWidget( new QLineEdit( this ) );
              layout->addWidget( new QLineEdit( this ) );
      
              QDialogButtonBox* box = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this );
              connect( box, SIGNAL(accepted()), this, SLOT(accept()) );
              connect( box, SIGNAL(rejected()), this, SLOT(reject()) );
              layout->addWidget( box );
      
              box->button(QDialogButtonBox::Ok)->setAutoDefault( false );
              box->button(QDialogButtonBox::Ok)->setDefault( false );
              box->button(QDialogButtonBox::Cancel)->setAutoDefault( false );
              box->button(QDialogButtonBox::Cancel)->setDefault( false );
          }
      };
      
      int main( int argc, char* argv[] )
      {
          QApplication app(argc, argv);
          
          MyDialog dlg;
          dlg.show();
      
          return app.exec();
      }
      

        Attachments

        1. main.cpp
          1 kB
          Bartlomiej Moskal
        2. OK_does_not_work.mp4
          735 kB
          Bartlomiej Moskal

          Issue Links

          For Gerrit Dashboard: QTBUG-61652
          # Subject Branch Project Status CR V

            Activity

              People

              Assignee:
              bartlomiejmoskal Bartlomiej Moskal
              Reporter:
              jpo38 Jean Porcherot
              Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:

                  Gerrit Reviews

                  There is 1 open Gerrit change