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

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

    XMLWordPrintable

Details

    • Android
    • e5686b35f07ea54f59e81d04a054bd832bee69b9 (qt/qtbase/dev) 05408a4e5fd1c411371983d75e361f23597cf4c7 (qt/tqtc-qtbase/5.15), 02f1e72d5 (dev)
    • 2022wk36FOQtforAndroid, 2022wk38FOQtforAndroid, 2022wk40FOQtforAndroid, 2022wk42FOQtforAndroid, 2022wk44FOQtforAndroid, 2022wk46FOQtforAndroid, 2022wk48FOQtforAndroid, 2022wk50FOQtforAndroid

    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. OK_does_not_work.mp4
          735 kB
        2. main.cpp
          1 kB

        Issue Links

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

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There is 1 open Gerrit change