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. How can i control android device keyboard?
Forum Updated to NodeBB v4.3 + New Features

How can i control android device keyboard?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
8 Posts 3 Posters 4.8k Views 3 Watching
  • 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.
  • H Offline
    H Offline
    Hakan AFAT
    wrote on 27 Mar 2018, 20:18 last edited by
    #1

    How can i control android device keyboard in Qml? Like prevent to closing?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 28 Mar 2018, 09:13 last edited by
      #2

      You can have (some) control of the keyboard by using Qt.inputMethod (documentation: https://doc.qt.io/qt-5/qinputmethod.html) and tweaking focuses through focus: true/false, forceActiveFocus() in each item.

      (Z(:^

      H 1 Reply Last reply 29 Mar 2018, 17:08
      2
      • S sierdzio
        28 Mar 2018, 09:13

        You can have (some) control of the keyboard by using Qt.inputMethod (documentation: https://doc.qt.io/qt-5/qinputmethod.html) and tweaking focuses through focus: true/false, forceActiveFocus() in each item.

        H Offline
        H Offline
        Hakan AFAT
        wrote on 29 Mar 2018, 17:08 last edited by
        #3

        @sierdzio On typing, it works great. Pops up the virtual keyboard and when my typing is done, i will be press the enter for onAccepted signal. But i need the change this action for disable closing the keyboard. How can i adapt this enter action on Qml?

        E 1 Reply Last reply 30 Mar 2018, 09:56
        0
        • S Offline
          S Offline
          sierdzio
          Moderators
          wrote on 30 Mar 2018, 06:06 last edited by
          #4

          You mean keyboard should stay visible?

          Here's an idea: detect the enter key (you do it in onAccepted if I understand you well. An alternative is to use Keys.onPressed), and in the slot switch focus to some off-screen control. Or, for that matter, switch it back to your current input. The keyboard should stay up this way.

          (Z(:^

          1 Reply Last reply
          0
          • H Hakan AFAT
            29 Mar 2018, 17:08

            @sierdzio On typing, it works great. Pops up the virtual keyboard and when my typing is done, i will be press the enter for onAccepted signal. But i need the change this action for disable closing the keyboard. How can i adapt this enter action on Qml?

            E Offline
            E Offline
            ekkescorner
            Qt Champions 2016
            wrote on 30 Mar 2018, 09:56 last edited by
            #5

            @Hakan-AFAT have you tried Keys.onReturnPressed to detect the Enter key and then:
            https://doc.qt.io/qt-5/qinputmethod.html#show

            ekke ... Qt Champion 2016 | 2024 ... mobile business apps
            5.15 --> 6.8 https://t1p.de/ekkeChecklist
            QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

            1 Reply Last reply
            1
            • H Offline
              H Offline
              Hakan AFAT
              wrote on 31 Mar 2018, 21:14 last edited by
              #6

              I was working on onPressed method QtQuick.Controls2. I got this error, ".onPressed" is not available due to component versioning." on android debug console.
              @sierdzio yes, it should stay visible.

              @ekkescorner i tried this one, too. But TextField signal onAccepted automatically hides the keyboard. Nothing happened with Keys.onReturnPressed. I need modify the onAccepted method on TextField. I found this in qt source, https://code.woboq.org/qt5/qtbase/src/gui/kernel/qinputmethod.cpp.html#214

              /*
                  Requests virtual keyboard to close.
                  Normally applications should not need to call this function,
                  keyboard should automatically close when the text editor loses
                  focus,((And if someone press enter)) for example when the parent view is closed.
              */
              void QInputMethod::hide()
              {
                  Q_D(QInputMethod);
                  QPlatformInputContext *ic = d->platformInputContext();
                  if (ic)
                      ic->hideInputPanel();
              }
              
              E 1 Reply Last reply 1 Apr 2018, 12:02
              0
              • H Hakan AFAT
                31 Mar 2018, 21:14

                I was working on onPressed method QtQuick.Controls2. I got this error, ".onPressed" is not available due to component versioning." on android debug console.
                @sierdzio yes, it should stay visible.

                @ekkescorner i tried this one, too. But TextField signal onAccepted automatically hides the keyboard. Nothing happened with Keys.onReturnPressed. I need modify the onAccepted method on TextField. I found this in qt source, https://code.woboq.org/qt5/qtbase/src/gui/kernel/qinputmethod.cpp.html#214

                /*
                    Requests virtual keyboard to close.
                    Normally applications should not need to call this function,
                    keyboard should automatically close when the text editor loses
                    focus,((And if someone press enter)) for example when the parent view is closed.
                */
                void QInputMethod::hide()
                {
                    Q_D(QInputMethod);
                    QPlatformInputContext *ic = d->platformInputContext();
                    if (ic)
                        ic->hideInputPanel();
                }
                
                E Offline
                E Offline
                ekkescorner
                Qt Champions 2016
                wrote on 1 Apr 2018, 12:02 last edited by
                #7

                @Hakan-AFAT if the keyboard closes even if you're switching focus back to the textfield or try to show()
                then as a workaround start a Timer to show() or forceActiveFocus()
                play with the delay - with some luck you'll find a value where Keyboard stays visible without flicker

                ekke ... Qt Champion 2016 | 2024 ... mobile business apps
                5.15 --> 6.8 https://t1p.de/ekkeChecklist
                QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  Hakan AFAT
                  wrote on 1 Apr 2018, 22:06 last edited by
                  #8

                  When i put Qt.inputMethod.show() in onAccepted method of textfield, it flicker :D. This didn't work.

                  I got same error with "forceActiveFocus". I don't found a correct way to update event on virtual keyboard.
                  Some testing component in source.
                  https://code.woboq.org/qt5/qtdeclarative/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp.html#_ZN19tst_qquicktextinput15signal_acceptedEv

                  I changed the textfield to textarea and a new manual enter button solved the problem temporarily.
                  At this time, text area goes over botttom of screen while i'm typing newline. This crashed too. :D

                  1 Reply Last reply
                  0

                  1/8

                  27 Mar 2018, 20:18

                  • Login

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