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. Qt/QML for Android - virtual keyboard key event handling
Forum Update on Monday, May 27th 2025

Qt/QML for Android - virtual keyboard key event handling

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 2 Posters 764 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
    Davronito
    wrote on 10 Sept 2019, 09:07 last edited by
    #1

    Hi Everybody!
    I've just joined in the Forum. I'm a beginner in Qt. I've faced a problem on QML. I'm making an app for Android. Created a TextInput object and when I press on it, it automatically sets a focus and the system-virtual keyboard appears. I handled some key events by Keys object, i.e: onReturnPressed, onBackPressed... So, I also need to handle the 'Plus' key, but onPressed event can't recognize it. Is there any solution for it? Here's my code:

    TextInput {

            property string placeholderText: "Input summ"
    
            id: txtin
            color: "black"
            anchors {
                top: summInfo.bottom
                topMargin: 20
                horizontalCenter: parent.horizontalCenter
            }
            width: parent.width-200
            height: 80
            text: ""
            font.pixelSize: 45
            horizontalAlignment: TextInput.AlignHCenter
            verticalAlignment: TextInput.AlignVCenter
            inputMethodHints: "ImhPreferNumbers"
            maximumLength: 9
            validator: DoubleValidator{
                notation: DoubleValidator.StandardNotation
                bottom: 0
                decimals: 2
            }
    
            Keys.onBackPressed: {
                centerFrame.focus = true
            }
    
            Keys.onPressed: {
                //if (event.key == Qt.Key_Plus) // HERE IS THE PROBLEM
                    console.log(event.key)
            }
    

    }

    R 1 Reply Last reply 11 Sept 2019, 07:32
    0
    • D Davronito
      10 Sept 2019, 09:07

      Hi Everybody!
      I've just joined in the Forum. I'm a beginner in Qt. I've faced a problem on QML. I'm making an app for Android. Created a TextInput object and when I press on it, it automatically sets a focus and the system-virtual keyboard appears. I handled some key events by Keys object, i.e: onReturnPressed, onBackPressed... So, I also need to handle the 'Plus' key, but onPressed event can't recognize it. Is there any solution for it? Here's my code:

      TextInput {

              property string placeholderText: "Input summ"
      
              id: txtin
              color: "black"
              anchors {
                  top: summInfo.bottom
                  topMargin: 20
                  horizontalCenter: parent.horizontalCenter
              }
              width: parent.width-200
              height: 80
              text: ""
              font.pixelSize: 45
              horizontalAlignment: TextInput.AlignHCenter
              verticalAlignment: TextInput.AlignVCenter
              inputMethodHints: "ImhPreferNumbers"
              maximumLength: 9
              validator: DoubleValidator{
                  notation: DoubleValidator.StandardNotation
                  bottom: 0
                  decimals: 2
              }
      
              Keys.onBackPressed: {
                  centerFrame.focus = true
              }
      
              Keys.onPressed: {
                  //if (event.key == Qt.Key_Plus) // HERE IS THE PROBLEM
                      console.log(event.key)
              }
      

      }

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 11 Sept 2019, 07:32 last edited by
      #2

      @davronito said in Qt/QML for Android - virtual keyboard key event handling:

      So, I also need to handle the 'Plus' key, but onPressed event can't recognize it.

      you mean that Keys.onPressed is not triggered at all for the plus key?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      D 1 Reply Last reply 11 Sept 2019, 08:09
      0
      • R raven-worx
        11 Sept 2019, 07:32

        @davronito said in Qt/QML for Android - virtual keyboard key event handling:

        So, I also need to handle the 'Plus' key, but onPressed event can't recognize it.

        you mean that Keys.onPressed is not triggered at all for the plus key?

        D Offline
        D Offline
        Davronito
        wrote on 11 Sept 2019, 08:09 last edited by
        #3

        @raven-worx yes, exactly. And I also tried Keys.onNumberSignPressed, but no effect yet

        1 Reply Last reply
        0

        1/3

        10 Sept 2019, 09:07

        • Login

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