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

QInputMethod visibleChanged signal fired incorrectly on Android

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4: Low
    • None
    • 5.7.0
    • QPA
    • Tested with devices running Android 4 and Android 6. This issue doesn't occur on iOS or Windows phone. I've tried compiling the code with both Qt 5.6 and Qt 5.7.
    • Android

    Description

      We are working on a pure openGL based mobile application (using QOpenGLWindow). We have no widgets or QML and we therefore need to handle user input ourselves. Qt provides QInputMethod for this purpose and it works very well, except in one problematic situation.

      If our application is started immediately after the phone is booted, when we show the keyboard the visibleChanged signal fires multpiple times and QInputMethod::isVisible() returns true and then false. This only happens the very first time the keyboard is shown. The false visibility signal is completely spurious.

      It is a problem for our app because we follow the state of the keyboard in order to display the correct controls to the user. If we receive false for the visibility we expect that this is because the user has manually hidden the keyboard (by pressing the back button).

      The problem is easy to reproduce with some simple code. Create a Qt Console application. Modify the .pro file to include the gui component (instead of excluding it) and modify main.cpp (see attachments)

      The debug output shows the following:
      1st time (immediately after phone has booted):
      Note spurious false / true messages
      W libKeyboardTest.so: (null):0 ((null)): show keyboard
      W libKeyboardTest.so: (null):0 ((null)): QObject::connect: No such signal TestWindow::cursorPositionChanged()
      W IInputConnectionWrapper: getCursorCapsMode on inactive InputConnection
      W IInputConnectionWrapper: getCursorCapsMode on inactive InputConnection
      W libKeyboardTest.so: (null):0 ((null)): keyboard Visibility changed: true
      W libKeyboardTest.so: (null):0 ((null)): keyboard Visibility changed: false
      W libKeyboardTest.so: (null):0 ((null)): QMetaObject::invokeMethod: No such method TestWindow::inputMethodQuery(Qt::InputMethodQuery,QVariant)
      D ViewRootImpl: MSG_RESIZED: ci=Rect(0, 96 - 0, 0) vi=Rect(0, 96 - 0, 1128) or=1
      W libKeyboardTest.so: (null):0 ((null)): keyboard Visibility changed: true
      W libKeyboardTest.so: (null):0 ((null)): QMetaObject::invokeMethod: No such method TestWindow::inputMethodQuery(Qt::InputMethodQuery,QVariant)
      V ActivityThread: updateVisibility : ActivityRecord{d3ef4e6 token=android.os.BinderProxy@92bdaf4 {org.qtproject.example.KeyboardTest/org.qtproject.qt5.android.bindings.QtActivity}} show : true

      Any other time (correct behaviour):
      W libKeyboardTest.so: (null):0 ((null)): show keyboard
      W libKeyboardTest.so: (null):0 ((null)): QObject::connect: No such signal TestWindow::cursorPositionChanged()
      W IInputConnectionWrapper: getCursorCapsMode on inactive InputConnection
      W libKeyboardTest.so: (null):0 ((null)): keyboard Visibility changed: true
      W libKeyboardTest.so: (null):0 ((null)): QMetaObject::invokeMethod: No such method TestWindow::inputMethodQuery(Qt::InputMethodQuery,QVariant)
      D ViewRootImpl: MSG_RESIZED: ci=Rect(0, 96 - 0, 0) vi=Rect(0, 96 - 0, 1128) or=1
      W libKeyboardTest.so: (null):0 ((null)): QMetaObject::invokeMethod: No such method TestWindow::inputMethodQuery(Qt::InputMethodQuery,QVariant)

      In our real application we have provided the missing cursorPositionChanged signal and inputMethodQuery(), so the visibility issue has nothing to do with that. Please can you investigate what is happening. Perhaps there is some uninitialised variable somewhere?

      Attachments

        1. KeyboardTest.pro
          0.1 kB
        2. main.cpp
          1 kB

        Issue Links

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

          Activity

            People

              mateusz.sobal Mateusz Sobal
              stuartfisher Stuart Fisher
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes