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

QScrollArea::ensureWidgetVisible() does not work properly on Android

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.2.0 Alpha
    • None
    • Android

    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.

      Attachments

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

        Activity

          People

            qtandroidteam Qt Android Team
            ivan.solovev Ivan Solovev
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes