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. Get Keyboard height in android

Get Keyboard height in android

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
6 Posts 4 Posters 1.5k 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.
  • S Offline
    S Offline
    Sheep
    wrote on 18 May 2023, 11:10 last edited by
    #1

    Greetings

    Am trying to get the height of the virtual keyboard in android using Qt.inputMethod::keyboardRectangle but i keep getting unexpected results (the Qt.inputMethod::keyboardRectangle.height is larger(almost 2 times) than the virtual keyboad height).

    i have noticed in the Qt documentation

    Qt.InputMethod::keyboardRectangle
    " Virtual keyboard's geometry in window coordinates."

    Then if the geometry is in window coodinates..then how can i convert them to qml units...
    Thanks
    Screenshot_20230518-135631.jpg

    J 1 Reply Last reply 18 May 2023, 17:03
    0
    • S Sheep
      18 May 2023, 11:10

      Greetings

      Am trying to get the height of the virtual keyboard in android using Qt.inputMethod::keyboardRectangle but i keep getting unexpected results (the Qt.inputMethod::keyboardRectangle.height is larger(almost 2 times) than the virtual keyboad height).

      i have noticed in the Qt documentation

      Qt.InputMethod::keyboardRectangle
      " Virtual keyboard's geometry in window coordinates."

      Then if the geometry is in window coodinates..then how can i convert them to qml units...
      Thanks
      Screenshot_20230518-135631.jpg

      J Offline
      J Offline
      JoeCFD
      wrote on 18 May 2023, 17:03 last edited by JoeCFD
      #2

      @Sheep if you can get the top left corner position of keyboard, you can calculate: screen height - top left corner y = keyboard height. That is pixel numbers and they can be used in qml.

      S 1 Reply Last reply 19 May 2023, 04:32
      0
      • J JoeCFD
        18 May 2023, 17:03

        @Sheep if you can get the top left corner position of keyboard, you can calculate: screen height - top left corner y = keyboard height. That is pixel numbers and they can be used in qml.

        S Offline
        S Offline
        Sheep
        wrote on 19 May 2023, 04:32 last edited by
        #3

        @JoeCFD Sorry for the late response, are you trying to mean I use the qt inputmethod. keyboard rectangle.y to get the top left

        J 1 Reply Last reply 19 May 2023, 14:58
        0
        • S Sheep
          19 May 2023, 04:32

          @JoeCFD Sorry for the late response, are you trying to mean I use the qt inputmethod. keyboard rectangle.y to get the top left

          J Offline
          J Offline
          JoeCFD
          wrote on 19 May 2023, 14:58 last edited by JoeCFD
          #4

          @Sheep That is what I meant. The unit of geometry data is pixel int and you can use the data in qml directly.
          I could be wrong. The coordinate y could be incorrect as well if the height is wrong. It is likely that your call to the func is too early.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Simon E.
            wrote on 8 May 2024, 12:12 last edited by
            #5

            Hello @Sheep we are having the same problem as you described. Did you manage to find a solution? Best Regards

            1 Reply Last reply
            0
            • A Offline
              A Offline
              AshkanV
              wrote on 11 Sept 2024, 14:05 last edited by
              #6

              The height is in native scale. It is required to devide it by devicePixelRatio:

              Qt.inputMethod.keyboardRectangle.height / Screen.devicePixelRatio
              
              1 Reply Last reply
              0

              • Login

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