Qt Mac: Escape key has no effect in a QDialog, if a QLineEdit or QSpinBox exists
-
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? -
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 ?
-
@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.
-
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(); }
-
I filed a bug for this: https://bugreports.qt.io/browse/QTBUG-103338