Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Impossible to detect keyboard visibility/size when using WebView on Android

Impossible to detect keyboard visibility/size when using WebView on Android

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
keyboardqmlandroidwebview
1 Posts 1 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    daljit97
    wrote on 16 Oct 2018, 18:17 last edited by daljit97
    #1

    So I am trying to find a way to detect whether the keyboard is visible in my Android application (Qt 5.11 on Linux, testing on Oreo). I have managed to do this partially using Qt.inputMethod.visible and also get the height with Qt.inputMethod.height. However, there is a big problem with this approach: it does not seem to work within a Qml WebView. When the use is visiting a webpage and hit a textfield, the previous method return 0 and hence I am unable to work out whether the keyboard is shown or not. Here is a sample code to reproduce the problem:

    import QtQuick 2.4
    import QtQuick.Controls 1.3
    import QtQuick.Window 2.2
    import QtQuick.Dialogs 1.2
    import QtWebView 1.0
    
    ApplicationWindow {
        title: qsTr("Hello World")
        width: 640
        height: 480
        visible: true
    
        Item{
            anchors.fill: parent
            WebView{
                id: webView
                url: "https://google.com"
                anchors.top: labelOut.bottom; anchors.bottom: parent.bottom
                anchors.left: parent.left; anchors.right: parent.right
            }
            Label {
                id: labelOut
                text: "Virtual Keyboard Visible: " + Qt.inputMethod.visible + " height: " + Qt.inputMethod.keyboardRectangle.height
                anchors.leftMargin: 4
                anchors.left: parent.left
                anchors.top: parent.top
                color: "black"
            }
    
        }
    }
    
    1 Reply Last reply
    0

    1/1

    16 Oct 2018, 18:17

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved