Qt6.8.2 iOS: Keyboard invisible in the background
-
I wrote a small application in C++ and compiled it now with qt 6.8.2. When I developed the app I used Qt 6.7.3. With this version everything worked as expected.
My app displays on startup a small dialog (QDialog) with 2 input lines and an OK button. When I tap to the first input line the cursor appears but no keyboard. But when I tap on the screen where the keyboard should be, the letters appearing in the input line. How can I bring the keyboard in forground? Or should I try to bring the app into the background?Here is a code snipped showing how the dialog is called:
bool THeating::login() { qDebug() << "DEBUG: THeating::login()"; TLogin *login = new TLogin(mParent); if (login->exec() == QDialog::Accepted) { mUser = login->getUser(); QString requestAuth = login->askForPermission(); if (requestAuth.length() == 0) { QMessageBox::critical(mParent, "THeating", tr("Ungültiger Benutzername oder Passwort!")); delete login; return false; } sendRequest(requestAuth); } else { QMessageBox::critical(mParent, "THeating", tr("Sie müssen einen gültigen Benutzernamen und ein Passwort eingeben!")); delete login; return false; } delete login; return true; }
This is the initialization of the dialog:
TLogin::TLogin(QWidget *parent) : QDialog(parent), ui(new Ui::TLogin) { qDebug() << "DEBUG: TLogin::TLogin(QWidget *parent)"; ui->setupUi(this); #if defined(__EMSCRIPTEN__) || defined(Q_OS_ANDROID) || defined(Q_OS_IOS) // We'll center the login dialog box QSize psize; QScreen *screen = parent->screen(); if (screen) psize = screen->size(); else psize = parent->size(); QRect lsize = geometry(); int left = (psize.width() - lsize.width()) / 2; int top = (psize.height() - lsize.height()) / 2; setGeometry(left, top, lsize.width(), lsize.height()); ui->lineEditUser->setFocusPolicy(Qt::StrongFocus); ui->lineEditPassword->setFocusPolicy(Qt::StrongFocus); ui->lineEditUser->setFocus(Qt::ActiveWindowFocusReason); #endif }
The 3 lines
ui->lineEditUser->setFocusPolicy(Qt::StrongFocus); ui->lineEditPassword->setFocusPolicy(Qt::StrongFocus); ui->lineEditUser->setFocus(Qt::ActiveWindowFocusReason);
don't change anything. Without them the behavior is the same.
Here is a screenshot of my app. You can see the frame around the top input line showing it has the focus.
On an emulator for iOS I can use the keyboard of my Mac to enter something. This works. But on a real device I have no visible keyboard.