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

Qt Mac: Escape key has no effect in a QDialog, if a QLineEdit or QSpinBox exists

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.2.0
    • None
    • macOS

    Description

      Pressing the escape button closes some dialogs on the Mac and does not on some others.

      This can be reproduced simply when calling

      bool resultOK = false;
      QInputDialog::getText(gMainWin, "Title", "text", QLineEdit::Normal, myVar &resultOK);

      This dialog is not closed when pressing the Escape Key.
      Custom dialogs will close using escape as long as the have no QLineEdit and no QSpinBox etc. If they have such a control, escape has no effect.

      The same code does not show this behavior on the windows build.

      I can reproduce this with a minimal sample, that just calls QInputDialog::getText. Pressing escape in this dialog has no effect.

      mainwindow.cpp:
      
      #include "mainwindow.h"
      #include <QInputDialog>
      
      MainWindow::MainWindow(QWidget *parent)
          : QMainWindow(parent)
      {
          bool resultOK = false;
          QString newName = QInputDialog::getText(this, "test", "entry", QLineEdit::Normal, "newentry", &resultOK );
      
      }
      
      MainWindow::~MainWindow()
      {
      }
      
      mainwindow.h
      
      #include <QMainWindow>
      
      class MainWindow : public QMainWindow
      {
          Q_OBJECT
      
      public:
          MainWindow(QWidget *parent = nullptr);
          ~MainWindow();
      };
      
      main.cpp
      
      #include "mainwindow.h"
      
      #include <QApplication>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          MainWindow w;
          w.show();
          return a.exec();
      }
      
      
      

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            stefanwoe Stefan Wörthmüller
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes