Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.2.0 Alpha
-
None
Description
The problem is visible when the Android keyboard pops up.
I have a scroll area with multiple line edits (the size of the scroll area is close to the size of the screen, or even more).
When I try to edit the line edit in the lower part of the screen, it's covered by the keyboard, so I can't see what I'm typing.
I tried to implement the following code to check if the keyboard is visible, and scroll the QScrollArea to show the needed widget:
QScrollArea *scrollArea = ...; // fill the QScrollArea with QLineEdit's QInputMethod *inputMethod = qApp->inputMethod(); connect(inputMethod, &QInputMethod::visibleChanged, [this, inputMethod]() { if (inputMethod->isVisible()) { QWidget *areaWidget = scrollArea->widget(); QList<QWidget*> childWidgets = areaWidget->findChildren<QWidget*>(); for (const auto widget : childWidgets) { if (widget->hasFocus()) { ui->scrollArea->ensureWidgetVisible(widget); break; } } } });
However it does not work
The problem is that ensureWidgetVisible() considers the focused widget to be still visible, so does nothing.
I suspect that it's because QInputMethod::keyboardRectangle() returns QRectF(0,0 0x0). So the size of the visible area is calculated incorrectly.