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 Updated to NodeBB v4.3 + New Features

Qt/QML for Android - virtual keyboard key event handling

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 2 Posters 769 Views 2 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.
  • DavronitoD Offline
    DavronitoD Offline
    Davronito
    wrote on 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)
            }
    

    }

    raven-worxR 1 Reply Last reply
    0
    • DavronitoD Davronito

      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)
              }
      

      }

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on 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

      DavronitoD 1 Reply Last reply
      0
      • raven-worxR raven-worx

        @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?

        DavronitoD Offline
        DavronitoD Offline
        Davronito
        wrote on last edited by
        #3

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

        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