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. Qt Mac: Escape key has no effect in a QDialog, if a QLineEdit or QSpinBox exists

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt6.2macos11windows10
8 Posts 4 Posters 780 Views
  • 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.
  • S Offline
    S Offline
    stefanwoe
    wrote on 4 May 2022, 17:00 last edited by
    #1

    Hello
    I figured that pressing 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.

    Is this possibly a configuration problem?
    Is there a solution / workaround?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 4 May 2022, 17:41 last edited by
      #2

      Hi,

      Which exact version of Qt are you using ?
      Which exact version of macOS ?

      Can you provide a full minimal compilable that shows this behaviour ?

      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
      • M Offline
        M Offline
        mchinand
        wrote on 4 May 2022, 18:00 last edited by mchinand 5 Apr 2022, 18:01
        #3

        Is the behavior different if the QLineEdit/QSpinBox in the dialog does or does not have keyboard focus?

        S 1 Reply Last reply 4 May 2022, 19:08
        0
        • S Offline
          S Offline
          stefanwoe
          wrote on 4 May 2022, 19:05 last edited by stefanwoe 5 Apr 2022, 19:06
          #4

          As stated in the Tags: Qt 6.2.0 MacOs11.6 I dont have a independent sample yet.

          1 Reply Last reply
          0
          • M mchinand
            4 May 2022, 18:00

            Is the behavior different if the QLineEdit/QSpinBox in the dialog does or does not have keyboard focus?

            S Offline
            S Offline
            stefanwoe
            wrote on 4 May 2022, 19:08 last edited by
            #5

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

            Is the behavior different if the QLineEdit/QSpinBox in the dialog does or does not have keyboard focus?

            I did not find a way to get the focus away from such controls. Any suggestions? But i think QInputDialog::getText is a perfect example.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              stefanwoe
              wrote on 4 May 2022, 19:30 last edited by stefanwoe 5 Apr 2022, 19:31
              #6

              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();
              }
              
              
              1 Reply Last reply
              0
              • S Offline
                S Offline
                stefanwoe
                wrote on 9 May 2022, 10:21 last edited by
                #7

                I filed a bug for this: https://bugreports.qt.io/browse/QTBUG-103338

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  artwaw
                  wrote on 9 May 2022, 11:16 last edited by
                  #8

                  I can't reproduce this on macOS 12.3.1 with Qt 6.3. Works as it should.

                  For more information please re-read.

                  Kind Regards,
                  Artur

                  1 Reply Last reply
                  0

                  1/8

                  4 May 2022, 17:00

                  • Login

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